Comments (10)
Thanks for reporting. I will have a closer look once in my office.
from enable3d.
I could not reproduce this error. The code below works fine.
class MainScene extends Scene3D {
async preload() {
await this.load.preload('man', '/assets/box_man.glb')
}
async create() {
this.warpSpeed()
this.load.gltf('man').then(gltf => {
const child = gltf.scene.children[0]
child.position.setX(-1)
this.scene.add(child)
})
this.load.gltf('man').then(gltf => {
const child = gltf.scene.children[0]
child.position.setX(1)
this.scene.add(child)
})
}
}
from enable3d.
Hi, sorry this is not what I meant. See example code below:
Working:
this.third.load.preload('ground', 'assets/ground.json');
this.third.load.preload('robot', 'assets/robot.glb');
this.third.load.object('ground').then((object) => {
//anything
});
Not working:
this.third.load.preload('robot', 'assets/robot.glb');
this.third.load.preload('ground', 'assets/ground.json');
this.third.load.object('ground').then((object) => {
//anything
});
Error message:
THREE:ObjectLoader: Can't parse assets/OBJ/ground.json. Unexpected token 'o', "[object ArrayBuffer]" is not valid JSON
As I said this is because line 66 in loaders.ts the responsetype is set to 'arraybuffer' for all files that are preloaded afterwards (in this case after robot.glb
).
from enable3d.
I see. I guess this would fix it?
public async preload(key: string, url: string) {
this.cache.add(key, url)
return new Promise(resolve => {
const isModel = /\.fbx$|\.glb$|\.gltf$/.test(url)
const isTexture = /\.jpe?g$|\.png$/.test(url)
if (isTexture) {
this.textureLoader.load(url, texture => {
return resolve(texture)
})
} else {
if (isModel) this.fileLoader.setResponseType('arraybuffer')
+ else this.fileLoader.setResponseType('undefined')
this.fileLoader.load(url, file => {
return resolve(file)
})
}
})
}
from enable3d.
Yes, that should do it. However, I think undefined
without quotations would be better.
from enable3d.
The responseType
can be undefined
or string
, but setResponseType
only takes a string
.
See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/three/src/loaders/FileLoader.d.ts
from enable3d.
True. Thanks for your help!
from enable3d.
This also seems to happen if you use load twice for the same fbx:
let object;
const key = 'assets/fbx/Male.fbx'
object = await this.third.load.fbx(key);
object = await this.third.load.fbx(key);
It cries with a:
three.module.js:43861 Uncaught (in promise) TypeError: url.lastIndexOf is not a function
at LoaderUtils.extractUrlBase (three.module.js:43861:1)
at FBXLoader.load (FBXLoader.js:79:51)
at loaders.js:157:1
at new Promise (<anonymous>)
at Loaders.fbx (loaders.js:156:1)
enable3d v0.25.4
Phaser v3.55.2 (WebGL | Web Audio)
from enable3d.
Try to preload your fbx file first.
from enable3d.
I cannot preload it, because the file to be loaded is dynamic (the name i set was an example).
Ex: multiplayer with 50 different avatars, not going to preload all of them.
This is my workaround:
// enable3d has a bug where FBXs can't be loaded more than once
// as they are saved as ArrayBuffers on cache
async loadFBX (key: string) {
if (this.currentScene.third.cache.get(key)) {
return await this.currentScene.third.load._fbxLoader.parse(this.currentScene.third.cache.get(key));
}
return await this.currentScene.third.load.fbx(key);
}
from enable3d.
Related Issues (20)
- physicsWorld.getWorldInfo() is not function inside @enable3d/ammo-physics HOT 6
- React JS doesn't support Enable3d HOT 2
- React JS doesn't support Enable3d HOT 2
- AmmoPhysics Error: abort(OOM). HOT 2
- Wrong typings? HOT 2
- The error that "require" cannot be used in rollup packaging occurs! HOT 5
- Crash Loading 3D Heightmap from PNG Example HOT 3
- Hello, I found a problem. Physical objects shake constantly during falling. How did this problem come about? HOT 2
- svg , other shapes then concave ? HOT 1
- Joystick on typescript in Phaser extension HOT 1
- Hide Powered by Enable3D? HOT 1
- IN @enable3d/phaser-extension Scene3D can not stop or start a scene HOT 3
- Does Enable3D support Inverse Kinematics (IK)?
- shape='box' Add rigid body, why my rigid body is bigger than the actual object, I don't know what's wrong. HOT 13
- I tried to pick-up objects and it didn't work out. HOT 4
- Uncaught RuntimeError: abort(OOM).
- In this example, pressing the A and D buttons has no effect! HOT 1
- THANK YOU FOR CREATING ENABLE3D!
- Removing physics object unlinks visuals and physics HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enable3d.