Cannot assign to read only property 'RGBA16F' of object in strict mode
See original GitHub issueEdit: This is caused by strict mode, see https://github.com/BabylonJS/Babylon.js/issues/2988#issuecomment-340539936
I have the exact same error as https://github.com/BabylonJS/Babylon.js/issues/2642 but the issue is closed and I don’t know why and how it has been resolved by OP
Context:
- Developing on
localhost
- With MacOSX and ArchLinux
- With Chrome and Firefox
- Using
babylonjs
as a CommonJS module with rollup (and babel) - With
babylon.3.0-beta12.max.js
andbabylon.3.0-beta12.js
(with and without npm)
Error:
babylon.3.0-beta12.max.js:7623 Uncaught TypeError: Cannot assign to read only property 'RGBA16F' of object '#<WebGL2RenderingContext>' at new Engine (babylon.3.0-beta12.max.js:7623)
It looks like the following WebGL constants RGBA16F
, RGBA32F
and DEPTH24_STENCIL8
are read only and cannot be set during engine creation.
Strangely HALF_FLOAT_OES
can be set without any problem…
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:16 (16 by maintainers)
Top Results From Across the Web
cannot assign to read-only property of object - Stack Overflow
the first approach you are mutating action.payload directly since you are not creating a copy to newItem but passing the same reference.
Read more >Cannot assign to read only property of Object in JavaScript
The error "Cannot assign to read only property of object" occurs when we try to change a property of an object that has...
Read more >PBR shader error on WebGL1.0 - Bugs - Babylon.js Forum
I can not seem to reproduce with other models ? ... Cannot assign to read only property 'RGBA16F' of object in strict mode....
Read more >JavaScript Cannot Assign to Read-only Property of Object in ...
Try and test HTML code online in a simple and easy way using our free HTML editor and see the results in real-time....
Read more >TypeError: "x" is read-only - JavaScript - MDN Web Docs
The JavaScript strict mode-only exception "is read-only" occurs when a global variable or object property that was assigned to is a read-only property....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@deltakosh I still have the issue with the latest release
I’ve seen that you’ve reverted the
if (...)
thing here in this commit 🤔 Why did you revert this? Is it related to strict check null #2982?I figured out exactly why this is happening using a bundler like rollup or webpack, the thing is that the bundler is enabling strict mode by default by adding
'use strict';
which is good for ES6In rollup documentation https://rollupjs.org/#strict
So I still have the problem with those 3 lines:
But also in
new Mesh(...)
at this line, theTools.DeepCopy
function is throwing at this line:The error details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only
Seems like
Mesh.source
is a getter (fromthis._source
) and then cannot be set ⚠️My workaround is to disable strict mode in my bundler, but I think there is several benefits to use strict mode directly in BabylonJS in development mode. In production mode we should be able to use it or not because there are many resources about performance improvements, see this and this and this.
@deltakosh do you want me to create 2 separate issues? Or to create another issue called Enable strict mode? Do you also think enabling strict mode is a good thing?
@vousk CC
I’m in a middle of an update so I’ll add it no worry 😃 (directly though)