Comments (4)
This also applies to other complex types: vec2, entity, ...
from engine.
Thanks @AlexAPPi, you've hit on an important point.
When an ES6 class members is defined, it is non configurable. Currently ScriptAttribute attempts to redefine the member using Object.defineProperty
which effectively becomes a no-op. This prevents the type conversion and attribute events from working.
class Test { fail = 'should be overridden' }
Object.defineProperty(Test.prototype, 'fail', { value: 100 });
test = new Test()
console.log(test.fail) // 'should be overridden'
I've created an editor repro here
For the time being, you'll need to avoid declaring attribute in the class body, or alternatively use the var MyClass = pc.createScript
syntax. We plan on solving this limitation with the newer ESM Scripts
from engine.
At the moment, the issue can be very obscure, as it doesn't warn the developer. This can lead to bugs that are hard to debug. We should add a warning.
from engine.
Yep this is not ideal, but unfortunately I don't think this is possible to catch at run-time without instantiating the class first. A solution is to prevent users using the class notation or declaring members in the class body. Neither are ideal.
from engine.
Related Issues (20)
- Gizmo movement plane HOT 5
- Gslang in engine examples runs our of memory in Safari
- Not loading TypeScript types definitions due to problematic "exports" field in package.json HOT 2
- Re-loading cubemaps fail to load associated textures HOT 2
- Ammo.js "table index is out of bounds" following Trigger destruction
- [Examples] `npm run develop` slower/bigger than it has to be HOT 1
- Question on multi-app HOT 2
- TypeError: e is not a constructor on loading glb model from ceisium HOT 2
- Inconsistencies with Anim component.
- Application crash HOT 2
- Some glb files are not rendered correctly
- Private Vercel bot Previews HOT 1
- Cannot create collision mesh using accessors
- Gizmo axis color does not restore when enabled (dsiabled=false)
- Neutral tonemapping does not implement exposure. HOT 1
- Gizmo keep selected when rotating camera
- Particles depend on camera angle HOT 1
- Why is there no Chinese documentation? HOT 3
- Is it possible to use IndexedDB to improve the loading speed of secondary renders? HOT 1
- Import URL resolution HOT 4
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 engine.