mergeTo TypeError: Cannot read property 'isPlaying' of null
Description:
- A-Frame Version: 0.7.0
- Platform / Device: chrome
- Reproducible Code Snippet or URL:
hello i tried to merge two objects with this simple code
<a-entity id="target" geometry="primitive: box; buffer: false; skipCache: true" material="color: red"></a-entity>
<a-entity geometry="primitive: box; buffer: false; skipCache: true; mergeTo: #target"
material="color: red" position="1 2 3"></a-entity>
and i receive this error
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'isPlaying' of null TypeError: Cannot read property 'isPlaying' of null
how is possible? i just tried the example of this page
https://github.com/aframevr/aframe/blob/master/docs/components/geometry.md
I think we should remove the mergeTo property, it works better if done manually versus declaratively (and it seems stale). I'd recommend merging manually in an A-Frame component what you need.
i tried but i have difficult to add the mesh to the component.
i've tried this simple code
AFRAME.registerComponent('mysquare', {
init: function(){
var el = this.el;
var box = new THREE.BoxGeometry(40, 5, 40);
var boxMesh = new THREE.Mesh(box);
boxMesh.position.set(25, 0, 25);
el.setObject3D("mesh", boxMesh);
}
})
i receive this error message
ERROR Error: Uncaught (in promise): Error: Entity.setObject3D was called with an object that was not an instance of THREE.Object3D.
Error: Entity.setObject3D was called with an object that was not an instance of THREE.Object3D.
at HTMLElement.value (aframe.js:73911)
at NewComponent.init (main.js:407)
at NewComponent.updateProperties (aframe.js:75409)
at HTMLElement.value (aframe.js:74256)
at HTMLElement.Object.create.updateComponents.value (aframe.js:74228)
at entityLoadCallback (aframe.js:74023)
at emitLoaded (aframe.js:74844)
at t.invoke (polyfills.js:3)
at Object.onInvoke (vendor.js:4247)
at t.invoke (polyfills.js:3)
at HTMLElement.value (aframe.js:73911)
at NewComponent.init (main.js:407)
at NewComponent.updateProperties (aframe.js:75409)
at HTMLElement.value (aframe.js:74256)
at HTMLElement.Object.create.updateComponents.value (aframe.js:74228)
at entityLoadCallback (aframe.js:74023)
at emitLoaded (aframe.js:74844)
at t.invoke (polyfills.js:3)
at Object.onInvoke (vendor.js:4247)
at t.invoke (polyfills.js:3)
at c (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (vendor.js:4238)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at
i tried also the 'add' function but i receive the same message. how is possible?
I'm good with eliminating mergeTo. It is confusing even for me that I implemented it 😄
We've removed mergeTo in favor of doing it manually in three.js (e.g., within a component) when needed. Instanced geometries is an alternative way to achieve the same draw call reductions. Quick resources on merging geometries in three.js:
- https://stackoverflow.com/questions/30245990/how-to-merge-two-geometries-or-meshes-using-three-js-r71
- http://blog.sandromartis.com/2016/11/16/merging-geometries/
- https://stackoverflow.com/questions/36450612/how-to-merge-two-buffergeometries-in-one-buffergeometry-in-three-js
- https://threejs.org/docs/#api/core/Geometry
We can provide more resources as we develop/evolve examples and code.
I made a geometry merge component: https://github.com/ngokevin/kframe/tree/master/components/geometry-merger#aframe-geometry-merger-component