in a-frame using angular setting directly gltf-model=“dracoDecoderPath:…
- User
in a-frame using angular setting directly gltf-model=“dracoDecoderPath: https://www.gstatic.com/draco/v1/decoders/; basisTranscoderPath:https://cdn.jsdelivr.net/npm/super-three@0.141.0/examples/js/libs/basis/;; meshoptDecoderPath: https://unpkg.com/meshoptimizer@~0.18.1/meshopt_decoder.js;”> its not working it load the scene already before setting the decoders
- Assistant
- User
how can i load meshopt in three loader?
- Assistant
- User
using this component what i do in the html?
this.aframe.registerComponent('model-decor', { schema: { dracoDecoderPath: {type: 'string'}, meshoptDecoderPath: {type: 'string'} }, init: function () { const {dracoDecoderPath, meshoptDecoderPath} = this.data; const loader = new THREE.GLTFLoader(); if (dracoDecoderPath) { const dracoLoader = new THREE.DRACOLoader(); dracoLoader.setDecoderPath(dracoDecoderPath); loader.setDRACOLoader(dracoLoader); } if (meshoptDecoderPath) { loader.setMeshoptDecoder(meshoptDecoderPath); } this.el.systems['gltf-model'].loader = loader; } }); - Assistant
- User
angular is not loading the gltf-model how i fix of a-frame how i fix that?
- Assistant
- User
this is the gltf-model code
var registerComponent = require('../core/component').registerComponent; var THREE = require('../lib/three'); var utils = require('../utils/'); var warn = utils.debug('components:gltf-model:warn');
/**
- glTF model loader. */ module.exports.Component = registerComponent('gltf-model', { schema: {type: 'model'},
init: function () { var self = this; var dracoLoader = this.system.getDRACOLoader(); var meshoptDecoder = this.system.getMeshoptDecoder(); var ktxLoader = this.system.getKTX2Loader(); this.model = null; this.loader = new THREE.GLTFLoader(); if (dracoLoader) { this.loader.setDRACOLoader(dracoLoader); } if (meshoptDecoder) { this.ready = meshoptDecoder.then(function (meshoptDecoder) { self.loader.setMeshoptDecoder(meshoptDecoder); }); } else { this.ready = Promise.resolve(); } if (ktxLoader) { this.loader.setKTX2Loader(ktxLoader); } },
- Assistant
- User
in angular doing this
doesnt works it cause the error components:gltf-model:warn THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files this is the gltf-model component code
var registerComponent = require('../core/component').registerComponent; var THREE = require('../lib/three'); var utils = require('../utils/'); var warn = utils.debug('components:gltf-model:warn');
/**
- glTF model loader. */ module.exports.Component = registerComponent('gltf-model', { schema: {type: 'model'},
- Assistant
- User
how can i fix this component and make my own component code to load first the loader and then add the model to the scene?
var registerComponent = require('../core/component').registerComponent; var THREE = require('../lib/three'); var utils = require('../utils/'); var warn = utils.debug('components:gltf-model:warn');
/**
- glTF model loader. */ module.exports.Component = registerComponent('gltf-model', { schema: {type: 'model'},
init: function () { var self = this; var dracoLoader = this.system.getDRACOLoader(); var meshoptDecoder = this.system.getMeshoptDecoder(); var ktxLoader = this.system.getKTX2Loader(); this.model = null; this.loader = new THREE.GLTFLoader(); if (dracoLoader) { this.loader.setDRACOLoader(dracoLoader); } if (meshoptDecoder) { this.ready = meshoptDecoder.then(function (meshoptDecoder) { self.loader.setMeshoptDecoder(meshoptDecoder); }); } else { this.ready = Promise.resolve(); } if (ktxLoader) { this.loader.setKTX2Loader(ktxLoader); } },
- Assistant
- User
but this is a model how i manage that in angular?
- Assistant
- User
how i integrate this code in my angular project without making an external js?
var registerComponent = require(‘aframe’).registerComponent; var THREE = require(‘three’); // Adjust according to your project’s way of importing THREE var warn = utils.debug(‘components:gltf-model:warn’);
module.exports.Component = registerComponent(‘gltf-model’, { schema: {type: ‘model’},
init: function () { this.setupLoaders().then(loaders => { this.loader = loaders.gltfLoader; }).catch(error => warn(‘Error setting up loaders’, error));
- Assistant
- User
i need to make this working
- Assistant
- User
if (this.data.dracoDecoderPath !== ‘’) { const dracoLoader = new THREE.DRACOLoader(); dracoLoader.setDecoderPath(this.data.dracoDecoderPath); loader.setDRACOLoader(dracoLoader); }
Write the same for meshoptDecoderPath and KTX2 decoder
- Assistant
- User
i need to fix this part if (this.data.meshoptDecoderPath !== '') { // The MeshoptDecoder should be a global function available when you include the meshopt decoder script // Ensure the meshoptDecoderPath script is included globally or perform necessary import/setup THREE.MeshoptDecoder.setDecoderPath(this.data.meshoptDecoderPath); THREE.MeshoptDecoder.wasmBinaryPath = ${this.data.meshoptDecoderPath}meshopt_decoder.wasm; loader.setMeshoptDecoder(THREE.MeshoptDecoder); }
this is the code from the official a-frame component if (meshoptDecoder) { this.ready = meshoptDecoder.then(function (meshoptDecoder) { self.loader.setMeshoptDecoder(meshoptDecoder); }); } else { this.ready = Promise.resolve(); }
- Assistant
- User
if (this.data.meshoptDecoderPath !== '') {
this contains the cdn pointing to the script i dont need to attach anything i need to load it
- Assistant
- User
export 'MeshoptDecoder' (imported as 'THREE') was not found in 'super-three'
- Assistant
- User
in my a-scene loaded with angular even light="defaultLightsEnabled: false" its not working
- Assistant
- User
i imported it like this [attr.gltf-model]="'dracoDecoderPath:https://cdn.jsdelivr.net/npm/three@0.158.0/examples/jsm/libs/draco/;basisTranscoderPath:https://cdn.jsdelivr.net/npm/three@0.158.0/examples/jsm/libs/basis/;meshoptDecoderPath:https://cdn.jsdelivr.net/npm/meshoptimizer@0.20.0/+esm'">
but im getting the following error: +esm:7 Uncaught SyntaxError: Unexpected token 'export' (at +esm:7:58944)
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.