DEVELOPERS / 3D
3D game runtime and integration
Technical guide for developers implementing or integrating 3D mechanics. The Studio teacher guide is a separate page.
Architecture, content and limits
Technical notes for custom 3D integrations.
For programmatic authoring, see the Node.js creation example.
Architecture
Educational logic is separated from rendering and physics. Three.js draw; Rapier calculates bodies and collisions; The quiz runtime maintains answers, scores, progress, and attempts.
Available mechanics
ordering-3dPhysical objects that are placed in ordered positions.
matching-3dLeft and right nodes that connect without altering the response model.
classification-3dObjects that are deposited in categories. It is a native type of the P2LRN questionnaire.
Classification question
This example shows the form of a classification question that can be represented within a 3D experience.
{
"id": "classify",
"type": "classification",
"prompt": "Classify the items by type.",
"points": 4,
"required": true,
"items": [
{"id": "dog", "text": "Dog"},
{"id": "oak", "text": "Oak"}
],
"categories": [
{"id": "animal", "text": "Animal"},
{"id": "plant", "text": "Plant"}
],
"solution": {
"assignments": [
{"item": "dog", "category": "animal"},
{"item": "oak", "category": "plant"}
]
}
}
The same type can be resolved with the standard renderer using accessible selectors or with the 3D renderer. The logical answer remains { classifications: { itemId: categoryId } }.
Create a 3D package
If you generate the course by code, add the quiz to the workspace and request the 3D presentation before building the package.
import {P2LRNAuthoringWorkspace} from '@p2lrn/toolkit/authoring';
const workspace = P2LRNAuthoringWorkspace.create('./workspace', {
title: 'Quest 3D portable',
language: 'en'
});
workspace.addQuestionnaire({
source: './quest-3d.json',
key: 'quest-3d',
title: 'Laboratorio Quest 3D',
renderer: 'https://p2lrn.org/renderer/questionnaire/3d-order-match'
});
workspace.build('./quest-3d-course.p2lrn', {
strictProfiles: true
});
The renderer preserves the historical identifier for compatibility 3d-order-match, although now it also supports classification.
Three.js and Rapier are within the distribution
The Player build fixes and verifies the versions before copying them to dist/vendor/. They are not downloaded from a third-party CDN during gameplay.
Three.js 0.186.1Scene, camera, lights, materials, raycasting and WebGL.
Rapier 3D 0.21.0Rigid bodies, colliders, gravity and physical step.
no-physicsLocal fallback if the physical engine cannot be initialized; maintains representation and controls.
Logic does not depend on physics
Operations like sorting, connecting, classifying, and ownership live in game-3d-mechanics.js. A change in physics engine does not change the answers or the educational calculation.
visual interaction
↓
{ kind: "classification-set",
itemId: "dog",
categoryId: "animal" }
↓
questionnaire answer
↓
score / progress / complete
Limitations
This runtime does not yet declare WebXR/Meta Quest or multiplayer sync as a P2LRN capability. The architecture leaves separate physical and mechanical inputs so they can be added later without linking the format to a specific LMS.
Teacher authoring and testing
To configure a 3D activity using the editor, follow the step-by-step teacher guide and check the learner preview before publishing.