diff --git a/ar_examples.js b/ar_examples.js index ce4b6a3..c9befae 100644 --- a/ar_examples.js +++ b/ar_examples.js @@ -10,6 +10,7 @@ class ARSimplestExample extends XRExampleBase { // Called during construction to allow the app to populate this.stageGroup (a THREE.Group) initializeStageGroup(){ + // Add a teapot at about eye level var geometry = new THREE.TeapotBufferGeometry(0.1) let materialColor = new THREE.Color() materialColor.setRGB(1.0, 1.0, 1.0) @@ -18,9 +19,17 @@ class ARSimplestExample extends XRExampleBase { side: THREE.DoubleSide }) let mesh = new THREE.Mesh(geometry, material) - mesh.position.set(0, 1.6, -1) + mesh.position.set(0, 1.4, -1) this.stageGroup.add(mesh) + // Add a box at the stage origin + let box = new THREE.Mesh( + new THREE.BoxBufferGeometry(0.1, 0.1, 0.1), + new THREE.MeshPhongMaterial({ color: '#DDFFDD' }) + ) + box.position.set(0, 0, 0) + this.stageGroup.add(box) + this.stageGroup.add(new THREE.AmbientLight('#FFF', 0.2)) let directionalLight = new THREE.DirectionalLight('#FFF', 0.6) directionalLight.position.set(0, 10, 0) @@ -30,7 +39,7 @@ class ARSimplestExample extends XRExampleBase { // Called once per frame, before render to give the app a chance to update this.stageGroup (a THREE.Group) updateStageGroup(frame, stageCoordinateSystem, stagePose){ // Uncomment the next line to spin the teapot - this.stageGroup.children[0].rotation.y += 0.01 + //this.stageGroup.children[0].rotation.y += 0.01 } } diff --git a/common_examples.js b/common_examples.js index 008b102..c6f07ee 100644 --- a/common_examples.js +++ b/common_examples.js @@ -153,7 +153,7 @@ class XRExampleBase { handleFrame(frame){ const nextFrameRequest = this.session.requestFrame(frame => { this.handleFrame(frame) }) - let stageCoordinateSystem = frame.getCoordinateSystem('stage') + let stageCoordinateSystem = frame.getCoordinateSystem(XRCoordinateSystem.STAGE) if(stageCoordinateSystem === null){ this.showMessage('Could not get a usable stage coordinate system') this.session.cancelFrame(nextFrameRequest) @@ -179,7 +179,7 @@ class XRExampleBase { this.scene.matrixAutoUpdate = false this.renderer.autoClear = false this.renderer.setSize(this.session.baseLayer.framebufferWidth, this.session.baseLayer.framebufferHeight, false) - //this.renderer.clear() + this.renderer.clear() //this.session.baseLayer.context.bindFramebuffer(this.session.baseLayer.context.FRAMEBUFFER, this.session.baseLayer.framebuffer) diff --git a/index.html b/index.html index 628cf41..5ff38be 100644 --- a/index.html +++ b/index.html @@ -9,8 +9,6 @@

XR Examples

-

The WebXR polyfill uses ES6 modules, so for now you'll need to enable them. -