@RaananW @brianzinn I think I got it working at least for my case.
It works when I use the relative path for babylonjs/core
like:
import {
Color3,
MeshBuilder,
Quaternion,
StandardMaterial,
Vector3,
} from "../node_modules/@babylonjs/core/index.js";
Which for my demo / development is ok.
But in general it comes down to BabylonJS not working with importmaps
as it doesn’t work if I try to load it like this:
<script type="importmap">
{
"imports": {
"@babylonjs/core": "https://unpkg.com/@babylonjs/core@5.28.0/index.js"
}
}
</script>
I’m getting ton of CORS errors in the console
Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockNormalGeometric.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:42 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockNormalGeometric.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Materials/Node/Blocks/Fragment/TBNBlock.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
clearCoatBlock.js:11 GET https://unpkg.com/@babylonjs/core@5.28.0/Materials/Node/Blocks/Fragment/TBNBlock.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrDebug.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:59 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrDebug.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/sceneVertexDeclaration.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
shadowMapVertexDeclaration.js:3 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/sceneVertexDeclaration.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockNormalFinal.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:44 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockNormalFinal.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockClearcoat.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:38 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockClearcoat.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:23 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockSheen.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:37 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockSheen.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockReflectance0.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
pbr.fragment.js:48 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/pbrBlockReflectance0.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/geometryVertexDeclaration.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
geometry.vertex.js:8 GET https://unpkg.com/@babylonjs/core@5.28.0/Shaders/ShadersInclude/geometryVertexDeclaration.js net::ERR_FAILED 502
localhost/:1 Access to script at 'https://unpkg.com/@babylonjs/core@5.28.0/Compute/computeShader.js' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
index.js:2 GET https://unpkg.com/@babylonjs/core@5.28.0/Compute/computeShader.js net::ERR_FAILED 520