MCPcopy Index your code
hub / github.com/aframevr/aframe / setObject3D

Method setObject3D

src/core/a-entity.js:124–151  ·  view source on GitHub ↗

* Set a THREE.Object3D into the map. * * @param {string} type - Developer-set name of the type of object, will be unique per type. * @param {THREE.Object3D} obj - A THREE.Object3D.

(type, obj)

Source from the content-addressed store, hash-verified

122 * @param {THREE.Object3D} obj - A THREE.Object3D.
123 */
124 setObject3D (type, obj) {
125 var oldObj;
126 var self = this;
127
128 if (!(obj instanceof THREE.Object3D)) {
129 throw new Error(
130 '`Entity.setObject3D` was called with an object that was not an instance of ' +
131 'THREE.Object3D.'
132 );
133 }
134
135 // Remove existing object of the type.
136 oldObj = this.getObject3D(type);
137 if (oldObj) { this.object3D.remove(oldObj); }
138
139 // Set references to A-Frame entity.
140 obj.el = this;
141 if (obj.children.length) {
142 obj.traverse(function bindEl (child) {
143 child.el = self;
144 });
145 }
146
147 // Add.
148 this.object3D.add(obj);
149 this.object3DMap[type] = obj;
150 this.emit('object3dset', {object: obj, type: type});
151 }
152
153 /**
154 * Remove object from scene and entity object3D map.

Callers 15

getOrCreateObject3DMethod · 0.95
line.jsFile · 0.80
geometry.jsFile · 0.80
sound.jsFile · 0.80
camera.jsFile · 0.80
hand-controls.jsFile · 0.80
obb-collider.jsFile · 0.80
text.jsFile · 0.80
gltf-model.jsFile · 0.80

Calls 4

getObject3DMethod · 0.95
removeMethod · 0.80
addMethod · 0.80
emitMethod · 0.80

Tested by

no test coverage detected