Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/face-target/aframe/face-occluder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ AFRAME.registerComponent(AR_COMPONENT_NAME.OCCULDER, {
el: null as any,

init: function () {
this.el.addEventListener(AR_EVENT_NAME.MODEL_LOADED, () => {
this.el.getObject3D(AR_ELEMENT_TAG.MESH).traverse((o: any) => {
if (o.isMesh) {
const material = new AFRAME.THREE.MeshStandardMaterial({
colorWrite: false,
});
this.el.addEventListener(AR_EVENT_NAME.MODEL_LOADED, this.onModelLoaded.bind(this));
this.el.addEventListener(AR_EVENT_NAME.MODEL_ERROR, this.onModelError.bind(this));
},

onModelLoaded: function () {
this.el.getObject3D(AR_ELEMENT_TAG.MESH).traverse((o: any) => {
if (o.isMesh) {
const material = new AFRAME.THREE.MeshStandardMaterial({
colorWrite: false,
});

o.material = material;
}
});
o.material = material;
}
});
},

onModelError: function () {
console.warn('Model failed to load.');
},
});
1 change: 1 addition & 0 deletions src/face-target/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const AR_COMPONENT_NAME = {

const AR_EVENT_NAME = {
MODEL_LOADED: 'model-loaded',
MODEL_ERROR: 'model-error',
TARGET_FOUND: 'face-targetFound',
TARGET_LOST: 'face-targetLost',
};
Expand Down