Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Error after adding ngt-physics #49

Closed
IRobot1 opened this issue Feb 14, 2022 · 2 comments
Closed

Error after adding ngt-physics #49

IRobot1 opened this issue Feb 14, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@IRobot1
Copy link
Contributor

IRobot1 commented Feb 14, 2022

Using latest 4.0.2 version of @angular/three.
Added cannon as follows
npm i @angular-three/cannon cannon-es
ng serve working fine.

Wrapped ngt-group with ngt-physics as follows

<ngt-group #group="ngtGroup" [name]="'room'">
<ngt-mesh *ngFor="let item of shapes"
[position]="item.position" [rotation]="item.rotation" [scale]="item.scale" [castShadow]="true" [receiveShadow]="true"
#mesh="ngtMesh">
<ngt-mesh-standard-material [parameters]="{ color: item.color, roughness: 0.7, metalness:0.0 }">
<ngt-box-geometry *ngIf="item.shapename=='box'" [args]="[0.2, 0.2, 0.2]">
<ngt-cone-geometry *ngIf="item.shapename=='cone'" [args]="[0.2, 0.2, 64]">
<ngt-cylinder-geometry *ngIf="item.shapename=='cylinder'" [args]="[ 0.2, 0.2, 0.2, 64]">
<ngt-icosahedron-geometry *ngIf="item.shapename=='icosahedron'" [args]="[ 0.2, 8]">
<ngt-torus-geometry *ngIf="item.shapename=='torus'" [args]="[ 0.2, 0.04, 64, 32]">


Browser console shows this error.

ERROR DOMException: Failed to construct 'Worker': Script at 'file:///C:/Users/adria/source/repos/angular-vr/node_modules/@angular-three/cannon/fesm2015/utils/worker.js' cannot be accessed from origin 'http://localhost:4200'.
at new NgtPhysicsStore (http://localhost:4200/vendor.js:20051:15)
at NodeInjectorFactory.NgtPhysicsStore_Factory [as factory] (http://localhost:4200/vendor.js:20280:10)
at getNodeInjectable (http://localhost:4200/vendor.js:42415:44)
at searchTokensOnInjector (http://localhost:4200/vendor.js:42352:16)
at getOrCreateInjectable (http://localhost:4200/vendor.js:42296:38)
at Module.ɵɵdirectiveInject (http://localhost:4200/vendor.js:53256:12)
at NodeInjectorFactory.NgtPhysics_Factory [as factory] (http://localhost:4200/vendor.js:20409:95)
at getNodeInjectable (http://localhost:4200/vendor.js:42415:44)
at instantiateAllDirectives (http://localhost:4200/vendor.js:49148:27)
at createDirectivesInstances (http://localhost:4200/vendor.js:48497:5)

Is there something I should be adding to angular.json or tsconfig.json?

@IRobot1 IRobot1 changed the title Error after adding @angular-three/cannon Error after adding ngt-physics Feb 14, 2022
@nartc
Copy link
Owner

nartc commented Feb 14, 2022

@IRobot1 Do not try 4.1.0. I tried fixing the error but it didn't work 😅. Apparently, I'd need to bundle the Worker somehow :)

@nartc nartc added the bug Something isn't working label Feb 15, 2022
@nartc
Copy link
Owner

nartc commented Feb 18, 2022

@IRobot1 this has been fixed with 4.2.4
Please use the generator: npx ng generate @angular-three/schematics:cannon <project-name>

  • <project-name> is the name of the application you want to add Cannon to. You can check the project name under angular.json file.

If you don't have @angular-three/schematics, install it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants