angular-three
v4.0.9
Published
Angular Renderer for THREE.js
Readme
angular-three
A custom Renderer for Angular 20+ that uses Three.js to render 3D scenes.
Documentation
All public APIs are documented with JSDoc comments. Your IDE will provide inline documentation, parameter hints, and examples as you code.
Official Documentation
Please visit Angular Three Documentation
Installation
npm install -D angular-three-plugin
npx ng generate angular-three-plugin:initUsage
- Create a
SceneGraphcomponent for your 3D scene graph
import { extend } from 'angular-three';
import { Mesh, BoxGeometry } from 'three';
extend({
Mesh, // makes ngt-mesh available
BoxGeometry, // makes ngt-box-geometry available
/* ... */
MyMesh: Mesh, // makes ngt-my-mesh available
});
// alternatively for demo purposes, you can use the following
// extend(THREE);
// This includes the entire THREE.js namespace
@Component({
selector: 'app-scene-graph',
template: `
<ngt-mesh>
<ngt-box-geometry />
</ngt-mesh>
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA], // required
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SceneGraph {}- Render the
SceneGraphwithNgtCanvas
import { NgtCanvas } from 'angular-three/dom';
import { SceneGraph } from './scene-graph';
@Component({
// This Component is rendered normally in Angular.
selector: 'app-my-experience',
template: `
<ngt-canvas>
<app-scene-graph *canvasContent />
</ngt-canvas>
`,
imports: [NgtCanvas],
})
export class MyExperience {}The Component that renders
NgtCanvas(MyExperiencein this case) controls the dimensions of the canvas so make sure to style it accordingly.
- Finally, provide the custom renderer in
bootstrapApplication
import { provideNgtRenderer } from 'angular-three/dom';
bootstrapApplication(AppComponent, {
providers: [provideNgtRenderer()],
});