angular-three-soba 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstractions/README.md +3 -0
- package/abstractions/index.d.ts +6 -0
- package/abstractions/lib/billboard/billboard.d.ts +14 -0
- package/abstractions/lib/gizmo-helper/gizmo-helper.d.ts +41 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.d.ts +12 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.d.ts +16 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.d.ts +24 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.d.ts +14 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.d.ts +15 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.d.ts +28 -0
- package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.d.ts +21 -0
- package/abstractions/lib/text/text.d.ts +21 -0
- package/abstractions/lib/text-3d/text-3d.d.ts +39 -0
- package/esm2020/abstractions/angular-three-soba-abstractions.mjs +5 -0
- package/esm2020/abstractions/index.mjs +7 -0
- package/esm2020/abstractions/lib/billboard/billboard.mjs +73 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-helper.mjs +206 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.mjs +31 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +91 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +182 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +45 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.mjs +133 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +193 -0
- package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.mjs +266 -0
- package/esm2020/abstractions/lib/text/text.mjs +110 -0
- package/esm2020/abstractions/lib/text-3d/text-3d.mjs +144 -0
- package/esm2020/cameras/lib/orthographic-camera/orthographic-camera.mjs +5 -5
- package/esm2020/staging/index.mjs +3 -1
- package/esm2020/staging/lib/camera-shake/camera-shake.mjs +121 -0
- package/esm2020/staging/lib/cloud/cloud.mjs +159 -0
- package/fesm2015/angular-three-soba-abstractions.mjs +1431 -0
- package/fesm2015/angular-three-soba-abstractions.mjs.map +1 -0
- package/fesm2015/angular-three-soba-cameras.mjs +4 -4
- package/fesm2015/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2015/angular-three-soba-staging.mjs +274 -4
- package/fesm2015/angular-three-soba-staging.mjs.map +1 -1
- package/fesm2020/angular-three-soba-abstractions.mjs +1428 -0
- package/fesm2020/angular-three-soba-abstractions.mjs.map +1 -0
- package/fesm2020/angular-three-soba-cameras.mjs +4 -4
- package/fesm2020/angular-three-soba-cameras.mjs.map +1 -1
- package/fesm2020/angular-three-soba-staging.mjs +274 -4
- package/fesm2020/angular-three-soba-staging.mjs.map +1 -1
- package/package.json +11 -3
- package/plugin/package.json +1 -1
- package/staging/index.d.ts +2 -0
- package/staging/lib/camera-shake/camera-shake.d.ts +28 -0
- package/staging/lib/cloud/cloud.d.ts +23 -0
|
@@ -0,0 +1,1428 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA, Input, InjectionToken, inject, Directive, EventEmitter, TemplateRef, Output, ContentChild } from '@angular/core';
|
|
3
|
+
import { extend, NgtRxStore, injectNgtRef, NgtStore, NgtPortal, NgtPortalContent, NgtArgs, NgtRepeat, startWithUndefined, NgtPush } from 'angular-three';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { Group, Vector3, Quaternion, Object3D, Matrix4, Mesh, BoxGeometry, MeshBasicMaterial, MeshLambertMaterial, CanvasTexture, AmbientLight, PointLight, Sprite, SpriteMaterial } from 'three';
|
|
6
|
+
import { NgTemplateOutlet, DOCUMENT, NgFor, NgIf } from '@angular/common';
|
|
7
|
+
import { selectSlice } from '@rx-angular/state';
|
|
8
|
+
import { NgtsOrthographicCamera } from 'angular-three-soba/cameras';
|
|
9
|
+
import { combineLatest, map, switchMap, of } from 'rxjs';
|
|
10
|
+
import { TextGeometry, FontLoader } from 'three-stdlib';
|
|
11
|
+
import { RxActionFactory } from '@rx-angular/state/actions';
|
|
12
|
+
import { Text, preloadFont } from 'troika-three-text';
|
|
13
|
+
|
|
14
|
+
extend({ Group });
|
|
15
|
+
class NgtsBillboard extends NgtRxStore {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.billboardRef = injectNgtRef();
|
|
19
|
+
}
|
|
20
|
+
set follow(follow) {
|
|
21
|
+
this.set({ follow });
|
|
22
|
+
}
|
|
23
|
+
set lockX(lockX) {
|
|
24
|
+
this.set({ lockX });
|
|
25
|
+
}
|
|
26
|
+
set lockY(lockY) {
|
|
27
|
+
this.set({ lockY });
|
|
28
|
+
}
|
|
29
|
+
set lockZ(lockZ) {
|
|
30
|
+
this.set({ lockZ });
|
|
31
|
+
}
|
|
32
|
+
initialize() {
|
|
33
|
+
super.initialize();
|
|
34
|
+
this.set({ follow: true, lockX: false, lockY: false, lockZ: false });
|
|
35
|
+
}
|
|
36
|
+
onBeforeRender(event) {
|
|
37
|
+
const { follow, lockX, lockY, lockZ } = this.get();
|
|
38
|
+
if (!follow)
|
|
39
|
+
return;
|
|
40
|
+
// save prev rotation in case we're locking axises
|
|
41
|
+
const prevRotation = event.object.rotation.clone();
|
|
42
|
+
// always face the camera
|
|
43
|
+
event.object.quaternion.copy(event.state.camera.quaternion);
|
|
44
|
+
// readjust any axis that is locked
|
|
45
|
+
if (lockX)
|
|
46
|
+
event.object.rotation.x = prevRotation.x;
|
|
47
|
+
if (lockY)
|
|
48
|
+
event.object.rotation.y = prevRotation.y;
|
|
49
|
+
if (lockZ)
|
|
50
|
+
event.object.rotation.z = prevRotation.z;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
NgtsBillboard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsBillboard, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
54
|
+
NgtsBillboard.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsBillboard, isStandalone: true, selector: "ngts-billboard", inputs: { billboardRef: "billboardRef", follow: "follow", lockX: "lockX", lockY: "lockY", lockZ: "lockZ" }, usesInheritance: true, ngImport: i0, template: `
|
|
55
|
+
<ngt-group ngtCompound [ref]="billboardRef" (beforeRender)="onBeforeRender($any($event))">
|
|
56
|
+
<ng-content />
|
|
57
|
+
</ngt-group>
|
|
58
|
+
`, isInline: true });
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsBillboard, decorators: [{
|
|
60
|
+
type: Component,
|
|
61
|
+
args: [{
|
|
62
|
+
selector: 'ngts-billboard',
|
|
63
|
+
standalone: true,
|
|
64
|
+
template: `
|
|
65
|
+
<ngt-group ngtCompound [ref]="billboardRef" (beforeRender)="onBeforeRender($any($event))">
|
|
66
|
+
<ng-content />
|
|
67
|
+
</ngt-group>
|
|
68
|
+
`,
|
|
69
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
70
|
+
}]
|
|
71
|
+
}], propDecorators: { billboardRef: [{
|
|
72
|
+
type: Input
|
|
73
|
+
}], follow: [{
|
|
74
|
+
type: Input
|
|
75
|
+
}], lockX: [{
|
|
76
|
+
type: Input
|
|
77
|
+
}], lockY: [{
|
|
78
|
+
type: Input
|
|
79
|
+
}], lockZ: [{
|
|
80
|
+
type: Input
|
|
81
|
+
}] } });
|
|
82
|
+
|
|
83
|
+
const isOrbitControls = (controls) => {
|
|
84
|
+
return 'minPolarAngle' in controls;
|
|
85
|
+
};
|
|
86
|
+
const NGTS_GIZMO_HELPER_API = new InjectionToken('NgtsGizmoHelper API');
|
|
87
|
+
function gizmoHelperApiFactory(gizmo) {
|
|
88
|
+
const store = inject(NgtStore);
|
|
89
|
+
return {
|
|
90
|
+
tweenCamera: (direction) => {
|
|
91
|
+
const { controls, camera, invalidate } = store.get();
|
|
92
|
+
const defaultControls = controls;
|
|
93
|
+
gizmo.animating = true;
|
|
94
|
+
if (defaultControls)
|
|
95
|
+
gizmo.focusPoint = defaultControls.target;
|
|
96
|
+
gizmo.radius = camera.position.distanceTo(gizmo.target);
|
|
97
|
+
// rotate from current camera orientation
|
|
98
|
+
gizmo.q1.copy(camera.quaternion);
|
|
99
|
+
// to new current camera orientation
|
|
100
|
+
gizmo.targetPosition.copy(direction).multiplyScalar(gizmo.radius).add(gizmo.target);
|
|
101
|
+
gizmo.dummy.lookAt(gizmo.targetPosition);
|
|
102
|
+
gizmo.q2.copy(gizmo.dummy.quaternion);
|
|
103
|
+
invalidate();
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
extend({ Group });
|
|
108
|
+
class NgtsGizmoHelperContent {
|
|
109
|
+
}
|
|
110
|
+
NgtsGizmoHelperContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoHelperContent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
111
|
+
NgtsGizmoHelperContent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoHelperContent, isStandalone: true, selector: "ng-template[ngtsGizmoHelperContent]", ngImport: i0 });
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoHelperContent, decorators: [{
|
|
113
|
+
type: Directive,
|
|
114
|
+
args: [{
|
|
115
|
+
selector: 'ng-template[ngtsGizmoHelperContent]',
|
|
116
|
+
standalone: true,
|
|
117
|
+
}]
|
|
118
|
+
}] });
|
|
119
|
+
class NgtsGizmoHelper extends NgtRxStore {
|
|
120
|
+
constructor() {
|
|
121
|
+
super(...arguments);
|
|
122
|
+
this.store = inject(NgtStore);
|
|
123
|
+
this.gizmoRef = injectNgtRef();
|
|
124
|
+
this.virtualCameraRef = injectNgtRef();
|
|
125
|
+
this.animating = false;
|
|
126
|
+
this.radius = 0;
|
|
127
|
+
this.focusPoint = new Vector3(0, 0, 0);
|
|
128
|
+
this.q1 = new Quaternion();
|
|
129
|
+
this.q2 = new Quaternion();
|
|
130
|
+
this.target = new Vector3();
|
|
131
|
+
this.targetPosition = new Vector3();
|
|
132
|
+
this.dummy = new Object3D();
|
|
133
|
+
this.defaultUp = new Vector3(0, 0, 0);
|
|
134
|
+
this.turnRate = 2 * Math.PI; // turn rate in angles per sec
|
|
135
|
+
this.matrix = new Matrix4();
|
|
136
|
+
this.updated = new EventEmitter();
|
|
137
|
+
}
|
|
138
|
+
set alignment(alignment) {
|
|
139
|
+
this.set({ alignment });
|
|
140
|
+
}
|
|
141
|
+
set margin(margin) {
|
|
142
|
+
this.set({ margin });
|
|
143
|
+
}
|
|
144
|
+
set renderPriority(renderPriority) {
|
|
145
|
+
this.set({ renderPriority });
|
|
146
|
+
}
|
|
147
|
+
set autoClear(autoClear) {
|
|
148
|
+
this.set({ autoClear });
|
|
149
|
+
}
|
|
150
|
+
initialize() {
|
|
151
|
+
super.initialize();
|
|
152
|
+
this.set({ alignment: 'bottom-right', margin: [80, 80], renderPriority: 1 });
|
|
153
|
+
}
|
|
154
|
+
ngOnInit() {
|
|
155
|
+
this.updateDefaultUp();
|
|
156
|
+
this.setGizmoPosition();
|
|
157
|
+
}
|
|
158
|
+
onBeforeRender(delta) {
|
|
159
|
+
if (this.virtualCameraRef.nativeElement && this.gizmoRef.nativeElement) {
|
|
160
|
+
const { controls, camera: mainCamera, invalidate } = this.store.get();
|
|
161
|
+
const defaultControls = controls;
|
|
162
|
+
// Animate step
|
|
163
|
+
if (this.animating) {
|
|
164
|
+
if (this.q1.angleTo(this.q2) < 0.01) {
|
|
165
|
+
this.animating = false;
|
|
166
|
+
// Orbit controls uses UP vector as the orbit axes,
|
|
167
|
+
// so we need to reset it after the animation is done
|
|
168
|
+
// moving it around for the controls to work correctly
|
|
169
|
+
if (isOrbitControls(defaultControls)) {
|
|
170
|
+
mainCamera.up.copy(this.defaultUp);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const step = delta * this.turnRate;
|
|
175
|
+
// animate position by doing a slerp and then scaling the position on the unit sphere
|
|
176
|
+
this.q1.rotateTowards(this.q2, step);
|
|
177
|
+
// animate orientation
|
|
178
|
+
mainCamera.position
|
|
179
|
+
.set(0, 0, 1)
|
|
180
|
+
.applyQuaternion(this.q1)
|
|
181
|
+
.multiplyScalar(this.radius)
|
|
182
|
+
.add(this.focusPoint);
|
|
183
|
+
mainCamera.up.set(0, 1, 0).applyQuaternion(this.q1).normalize();
|
|
184
|
+
mainCamera.quaternion.copy(this.q1);
|
|
185
|
+
if (this.updated.observed)
|
|
186
|
+
this.updated.emit();
|
|
187
|
+
else if (defaultControls) {
|
|
188
|
+
defaultControls.update();
|
|
189
|
+
}
|
|
190
|
+
invalidate();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Sync Gizmo with main camera orientation
|
|
194
|
+
this.matrix.copy(mainCamera.matrix).invert();
|
|
195
|
+
this.gizmoRef.nativeElement.quaternion.setFromRotationMatrix(this.matrix);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
setGizmoPosition() {
|
|
199
|
+
this.connect('gizmoPosition', combineLatest([this.store.select('size'), this.select(selectSlice(['alignment', 'margin']))]).pipe(map(([size, { alignment, margin }]) => {
|
|
200
|
+
const [marginX, marginY] = margin;
|
|
201
|
+
const x = alignment.endsWith('-center')
|
|
202
|
+
? 0
|
|
203
|
+
: alignment.endsWith('-left')
|
|
204
|
+
? -size.width / 2 + marginX
|
|
205
|
+
: size.width / 2 - marginX;
|
|
206
|
+
const y = alignment.startsWith('center-')
|
|
207
|
+
? 0
|
|
208
|
+
: alignment.startsWith('top-')
|
|
209
|
+
? size.height / 2 - marginY
|
|
210
|
+
: -size.height / 2 + marginY;
|
|
211
|
+
return [x, y, 0];
|
|
212
|
+
})));
|
|
213
|
+
}
|
|
214
|
+
updateDefaultUp() {
|
|
215
|
+
this.hold(this.store.select('camera'), (camera) => {
|
|
216
|
+
this.defaultUp.copy(camera.up);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
NgtsGizmoHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoHelper, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
221
|
+
NgtsGizmoHelper.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoHelper, isStandalone: true, selector: "ngts-gizmo-helper", inputs: { alignment: "alignment", margin: "margin", renderPriority: "renderPriority", autoClear: "autoClear" }, outputs: { updated: "updated" }, providers: [{ provide: NGTS_GIZMO_HELPER_API, useFactory: gizmoHelperApiFactory, deps: [NgtsGizmoHelper] }], queries: [{ propertyName: "gizmoHelperContent", first: true, predicate: NgtsGizmoHelperContent, descendants: true, read: TemplateRef, static: true }], usesInheritance: true, ngImport: i0, template: `
|
|
222
|
+
<ngt-portal [renderPriority]="get('renderPriority')">
|
|
223
|
+
<ng-template ngtPortalContent>
|
|
224
|
+
<ngts-orthographic-camera
|
|
225
|
+
[cameraRef]="virtualCameraRef"
|
|
226
|
+
[makeDefault]="true"
|
|
227
|
+
[position]="[0, 0, 200]"
|
|
228
|
+
/>
|
|
229
|
+
<ngt-group
|
|
230
|
+
[ref]="gizmoRef"
|
|
231
|
+
[position]="get('gizmoPosition')"
|
|
232
|
+
(beforeRender)="onBeforeRender($any($event).state.delta)"
|
|
233
|
+
>
|
|
234
|
+
<ng-container *ngTemplateOutlet="gizmoHelperContent" />
|
|
235
|
+
</ngt-group>
|
|
236
|
+
</ng-template>
|
|
237
|
+
</ngt-portal>
|
|
238
|
+
`, isInline: true, dependencies: [{ kind: "component", type: NgtPortal, selector: "ngt-portal", inputs: ["container", "state", "autoRender", "autoRenderPriority"], outputs: ["beforeRender"] }, { kind: "directive", type: NgtPortalContent, selector: "ng-template[ngtPortalContent]" }, { kind: "component", type: NgtsOrthographicCamera, selector: "ngts-orthographic-camera", inputs: ["left", "right", "top", "bottom"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
239
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoHelper, decorators: [{
|
|
240
|
+
type: Component,
|
|
241
|
+
args: [{
|
|
242
|
+
selector: 'ngts-gizmo-helper',
|
|
243
|
+
standalone: true,
|
|
244
|
+
template: `
|
|
245
|
+
<ngt-portal [renderPriority]="get('renderPriority')">
|
|
246
|
+
<ng-template ngtPortalContent>
|
|
247
|
+
<ngts-orthographic-camera
|
|
248
|
+
[cameraRef]="virtualCameraRef"
|
|
249
|
+
[makeDefault]="true"
|
|
250
|
+
[position]="[0, 0, 200]"
|
|
251
|
+
/>
|
|
252
|
+
<ngt-group
|
|
253
|
+
[ref]="gizmoRef"
|
|
254
|
+
[position]="get('gizmoPosition')"
|
|
255
|
+
(beforeRender)="onBeforeRender($any($event).state.delta)"
|
|
256
|
+
>
|
|
257
|
+
<ng-container *ngTemplateOutlet="gizmoHelperContent" />
|
|
258
|
+
</ngt-group>
|
|
259
|
+
</ng-template>
|
|
260
|
+
</ngt-portal>
|
|
261
|
+
`,
|
|
262
|
+
imports: [NgtPortal, NgtPortalContent, NgtsOrthographicCamera, NgTemplateOutlet],
|
|
263
|
+
providers: [{ provide: NGTS_GIZMO_HELPER_API, useFactory: gizmoHelperApiFactory, deps: [NgtsGizmoHelper] }],
|
|
264
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
265
|
+
}]
|
|
266
|
+
}], propDecorators: { alignment: [{
|
|
267
|
+
type: Input
|
|
268
|
+
}], margin: [{
|
|
269
|
+
type: Input
|
|
270
|
+
}], renderPriority: [{
|
|
271
|
+
type: Input
|
|
272
|
+
}], autoClear: [{
|
|
273
|
+
type: Input
|
|
274
|
+
}], updated: [{
|
|
275
|
+
type: Output
|
|
276
|
+
}], gizmoHelperContent: [{
|
|
277
|
+
type: ContentChild,
|
|
278
|
+
args: [NgtsGizmoHelperContent, { static: true, read: TemplateRef }]
|
|
279
|
+
}] } });
|
|
280
|
+
|
|
281
|
+
const colors = { bg: '#f0f0f0', hover: '#999', text: 'black', stroke: 'black' };
|
|
282
|
+
const defaultFaces = ['Right', 'Left', 'Top', 'Bottom', 'Front', 'Back'];
|
|
283
|
+
const makePositionVector = (xyz) => new THREE.Vector3(...xyz).multiplyScalar(0.38);
|
|
284
|
+
const corners = [
|
|
285
|
+
[1, 1, 1],
|
|
286
|
+
[1, 1, -1],
|
|
287
|
+
[1, -1, 1],
|
|
288
|
+
[1, -1, -1],
|
|
289
|
+
[-1, 1, 1],
|
|
290
|
+
[-1, 1, -1],
|
|
291
|
+
[-1, -1, 1],
|
|
292
|
+
[-1, -1, -1],
|
|
293
|
+
].map(makePositionVector);
|
|
294
|
+
const cornerDimensions = [0.25, 0.25, 0.25];
|
|
295
|
+
const edges = [
|
|
296
|
+
[1, 1, 0],
|
|
297
|
+
[1, 0, 1],
|
|
298
|
+
[1, 0, -1],
|
|
299
|
+
[1, -1, 0],
|
|
300
|
+
[0, 1, 1],
|
|
301
|
+
[0, 1, -1],
|
|
302
|
+
[0, -1, 1],
|
|
303
|
+
[0, -1, -1],
|
|
304
|
+
[-1, 1, 0],
|
|
305
|
+
[-1, 0, 1],
|
|
306
|
+
[-1, 0, -1],
|
|
307
|
+
[-1, -1, 0],
|
|
308
|
+
].map(makePositionVector);
|
|
309
|
+
const edgeDimensions = edges.map((edge) => edge.toArray().map((axis) => (axis == 0 ? 0.5 : 0.25)));
|
|
310
|
+
|
|
311
|
+
class NgtsGizmoViewcubeInputs extends NgtRxStore {
|
|
312
|
+
constructor() {
|
|
313
|
+
super(...arguments);
|
|
314
|
+
this.store = inject(NgtStore);
|
|
315
|
+
}
|
|
316
|
+
set opacity(opacity) {
|
|
317
|
+
this.set({ opacity });
|
|
318
|
+
}
|
|
319
|
+
set hoverColor(hoverColor) {
|
|
320
|
+
this.set({ hoverColor });
|
|
321
|
+
}
|
|
322
|
+
set textColor(textColor) {
|
|
323
|
+
this.set({ textColor });
|
|
324
|
+
}
|
|
325
|
+
set strokeColor(strokeColor) {
|
|
326
|
+
this.set({ strokeColor });
|
|
327
|
+
}
|
|
328
|
+
set faces(faces) {
|
|
329
|
+
this.set({ faces });
|
|
330
|
+
}
|
|
331
|
+
set clickEmitter(clickEmitter) {
|
|
332
|
+
this.set({ clickEmitter });
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
NgtsGizmoViewcubeInputs.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeInputs, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
336
|
+
NgtsGizmoViewcubeInputs.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewcubeInputs, inputs: { opacity: "opacity", hoverColor: "hoverColor", textColor: "textColor", strokeColor: "strokeColor", faces: "faces", clickEmitter: "clickEmitter" }, usesInheritance: true, ngImport: i0 });
|
|
337
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeInputs, decorators: [{
|
|
338
|
+
type: Directive
|
|
339
|
+
}], propDecorators: { opacity: [{
|
|
340
|
+
type: Input
|
|
341
|
+
}], hoverColor: [{
|
|
342
|
+
type: Input
|
|
343
|
+
}], textColor: [{
|
|
344
|
+
type: Input
|
|
345
|
+
}], strokeColor: [{
|
|
346
|
+
type: Input
|
|
347
|
+
}], faces: [{
|
|
348
|
+
type: Input
|
|
349
|
+
}], clickEmitter: [{
|
|
350
|
+
type: Input
|
|
351
|
+
}] } });
|
|
352
|
+
|
|
353
|
+
extend({ Mesh, BoxGeometry, MeshBasicMaterial });
|
|
354
|
+
class NgtsGizmoViewcubeEdgeCube extends NgtsGizmoViewcubeInputs {
|
|
355
|
+
constructor() {
|
|
356
|
+
super(...arguments);
|
|
357
|
+
this.gizmoHelperApi = inject(NGTS_GIZMO_HELPER_API);
|
|
358
|
+
this.hover = false;
|
|
359
|
+
}
|
|
360
|
+
set dimensions(dimensions) {
|
|
361
|
+
this.set({ dimensions });
|
|
362
|
+
}
|
|
363
|
+
set position(position) {
|
|
364
|
+
this.set({ position });
|
|
365
|
+
}
|
|
366
|
+
initialize() {
|
|
367
|
+
super.initialize();
|
|
368
|
+
this.set({ hoverColor: colors.hover });
|
|
369
|
+
}
|
|
370
|
+
onPointerMove(event) {
|
|
371
|
+
event.stopPropagation();
|
|
372
|
+
this.hover = true;
|
|
373
|
+
}
|
|
374
|
+
onPointerOut(event) {
|
|
375
|
+
event.stopPropagation();
|
|
376
|
+
this.hover = false;
|
|
377
|
+
}
|
|
378
|
+
onClick(event) {
|
|
379
|
+
if (this.get('clickEmitter')?.observed) {
|
|
380
|
+
this.get('clickEmitter').emit(event);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
event.stopPropagation();
|
|
384
|
+
this.gizmoHelperApi.tweenCamera(this.get('position'));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
NgtsGizmoViewcubeEdgeCube.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeEdgeCube, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
389
|
+
NgtsGizmoViewcubeEdgeCube.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewcubeEdgeCube, isStandalone: true, selector: "ngts-gizmo-viewcube-edge-cube[dimensions][position]", inputs: { dimensions: "dimensions", position: "position" }, usesInheritance: true, ngImport: i0, template: `
|
|
390
|
+
<ngt-mesh
|
|
391
|
+
[scale]="1.01"
|
|
392
|
+
[position]="get('position')"
|
|
393
|
+
(pointermove)="onPointerMove($any($event))"
|
|
394
|
+
(pointerout)="onPointerOut($any($event))"
|
|
395
|
+
(click)="onClick($any($event))"
|
|
396
|
+
>
|
|
397
|
+
<ngt-box-geometry *args="get('dimensions')" />
|
|
398
|
+
<ngt-mesh-basic-material
|
|
399
|
+
[color]="hover ? get('hoverColor') : 'white'"
|
|
400
|
+
[transparent]="true"
|
|
401
|
+
[opacity]="0.6"
|
|
402
|
+
[visible]="hover"
|
|
403
|
+
/>
|
|
404
|
+
</ngt-mesh>
|
|
405
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
|
|
406
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeEdgeCube, decorators: [{
|
|
407
|
+
type: Component,
|
|
408
|
+
args: [{
|
|
409
|
+
selector: 'ngts-gizmo-viewcube-edge-cube[dimensions][position]',
|
|
410
|
+
standalone: true,
|
|
411
|
+
template: `
|
|
412
|
+
<ngt-mesh
|
|
413
|
+
[scale]="1.01"
|
|
414
|
+
[position]="get('position')"
|
|
415
|
+
(pointermove)="onPointerMove($any($event))"
|
|
416
|
+
(pointerout)="onPointerOut($any($event))"
|
|
417
|
+
(click)="onClick($any($event))"
|
|
418
|
+
>
|
|
419
|
+
<ngt-box-geometry *args="get('dimensions')" />
|
|
420
|
+
<ngt-mesh-basic-material
|
|
421
|
+
[color]="hover ? get('hoverColor') : 'white'"
|
|
422
|
+
[transparent]="true"
|
|
423
|
+
[opacity]="0.6"
|
|
424
|
+
[visible]="hover"
|
|
425
|
+
/>
|
|
426
|
+
</ngt-mesh>
|
|
427
|
+
`,
|
|
428
|
+
imports: [NgtArgs],
|
|
429
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
430
|
+
}]
|
|
431
|
+
}], propDecorators: { dimensions: [{
|
|
432
|
+
type: Input
|
|
433
|
+
}], position: [{
|
|
434
|
+
type: Input
|
|
435
|
+
}] } });
|
|
436
|
+
|
|
437
|
+
extend({ MeshLambertMaterial, Mesh, BoxGeometry });
|
|
438
|
+
class NgtsGizmoViewcubeFaceMaterial extends NgtsGizmoViewcubeInputs {
|
|
439
|
+
constructor() {
|
|
440
|
+
super(...arguments);
|
|
441
|
+
this.document = inject(DOCUMENT);
|
|
442
|
+
}
|
|
443
|
+
set index(index) {
|
|
444
|
+
this.set({ index });
|
|
445
|
+
}
|
|
446
|
+
set hover(hover) {
|
|
447
|
+
this.set({ hover });
|
|
448
|
+
}
|
|
449
|
+
set font(font) {
|
|
450
|
+
this.set({ font });
|
|
451
|
+
}
|
|
452
|
+
set color(color) {
|
|
453
|
+
this.set({ color });
|
|
454
|
+
}
|
|
455
|
+
initialize() {
|
|
456
|
+
super.initialize();
|
|
457
|
+
this.set({
|
|
458
|
+
font: '20px Inter var, Arial, sans-serif',
|
|
459
|
+
faces: defaultFaces,
|
|
460
|
+
color: colors.bg,
|
|
461
|
+
hoverColor: colors.hover,
|
|
462
|
+
textColor: colors.text,
|
|
463
|
+
strokeColor: colors.stroke,
|
|
464
|
+
opacity: 1,
|
|
465
|
+
});
|
|
466
|
+
this.connect('texture', this.select(['index', 'faces', 'color', 'font', 'textColor', 'strokeColor'], ({ index, faces, color, font, textColor, strokeColor }) => {
|
|
467
|
+
const canvas = this.document.createElement('canvas');
|
|
468
|
+
canvas.width = 128;
|
|
469
|
+
canvas.height = 128;
|
|
470
|
+
const context = canvas.getContext('2d');
|
|
471
|
+
context.fillStyle = color;
|
|
472
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
473
|
+
context.strokeStyle = strokeColor;
|
|
474
|
+
context.strokeRect(0, 0, canvas.width, canvas.height);
|
|
475
|
+
context.font = font;
|
|
476
|
+
context.textAlign = 'center';
|
|
477
|
+
context.fillStyle = textColor;
|
|
478
|
+
context.fillText(faces[index].toUpperCase(), 64, 76);
|
|
479
|
+
return new CanvasTexture(canvas);
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
NgtsGizmoViewcubeFaceMaterial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeFaceMaterial, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
484
|
+
NgtsGizmoViewcubeFaceMaterial.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewcubeFaceMaterial, isStandalone: true, selector: "ngts-gizmo-viewcube-face-material[hover][index]", inputs: { index: "index", hover: "hover", font: "font", color: "color" }, usesInheritance: true, ngImport: i0, template: `
|
|
485
|
+
<ngt-mesh-lambert-material
|
|
486
|
+
[attach]="['material', get('index')]"
|
|
487
|
+
[map]="get('texture')"
|
|
488
|
+
[color]="get('hover') ? get('hoverColor') : get('color')"
|
|
489
|
+
[opacity]="get('opacity')"
|
|
490
|
+
[transparent]="true"
|
|
491
|
+
>
|
|
492
|
+
<ngt-value [rawValue]="store.get('gl').outputEncoding" attach="map.encoding" />
|
|
493
|
+
<ngt-value [rawValue]="store.get('gl').capabilities.getMaxAnisotropy() || 1" attach="map.anisotrophy" />
|
|
494
|
+
</ngt-mesh-lambert-material>
|
|
495
|
+
`, isInline: true });
|
|
496
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeFaceMaterial, decorators: [{
|
|
497
|
+
type: Component,
|
|
498
|
+
args: [{
|
|
499
|
+
selector: 'ngts-gizmo-viewcube-face-material[hover][index]',
|
|
500
|
+
standalone: true,
|
|
501
|
+
template: `
|
|
502
|
+
<ngt-mesh-lambert-material
|
|
503
|
+
[attach]="['material', get('index')]"
|
|
504
|
+
[map]="get('texture')"
|
|
505
|
+
[color]="get('hover') ? get('hoverColor') : get('color')"
|
|
506
|
+
[opacity]="get('opacity')"
|
|
507
|
+
[transparent]="true"
|
|
508
|
+
>
|
|
509
|
+
<ngt-value [rawValue]="store.get('gl').outputEncoding" attach="map.encoding" />
|
|
510
|
+
<ngt-value [rawValue]="store.get('gl').capabilities.getMaxAnisotropy() || 1" attach="map.anisotrophy" />
|
|
511
|
+
</ngt-mesh-lambert-material>
|
|
512
|
+
`,
|
|
513
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
514
|
+
}]
|
|
515
|
+
}], propDecorators: { index: [{
|
|
516
|
+
type: Input
|
|
517
|
+
}], hover: [{
|
|
518
|
+
type: Input
|
|
519
|
+
}], font: [{
|
|
520
|
+
type: Input
|
|
521
|
+
}], color: [{
|
|
522
|
+
type: Input
|
|
523
|
+
}] } });
|
|
524
|
+
class NgtsGizmoViewcubeFaceCube extends NgtsGizmoViewcubeInputs {
|
|
525
|
+
constructor() {
|
|
526
|
+
super(...arguments);
|
|
527
|
+
this.gizmoHelperApi = inject(NGTS_GIZMO_HELPER_API);
|
|
528
|
+
this.hover = -1;
|
|
529
|
+
}
|
|
530
|
+
set font(font) {
|
|
531
|
+
this.set({ font });
|
|
532
|
+
}
|
|
533
|
+
set color(color) {
|
|
534
|
+
this.set({ color });
|
|
535
|
+
}
|
|
536
|
+
onPointerMove(event) {
|
|
537
|
+
event.stopPropagation();
|
|
538
|
+
this.hover = Math.floor(event.faceIndex / 2);
|
|
539
|
+
}
|
|
540
|
+
onPointerOut(event) {
|
|
541
|
+
event.stopPropagation();
|
|
542
|
+
this.hover = -1;
|
|
543
|
+
}
|
|
544
|
+
onClick(event) {
|
|
545
|
+
if (this.get('clickEmitter')?.observed) {
|
|
546
|
+
this.get('clickEmitter').emit(event);
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
event.stopPropagation();
|
|
550
|
+
this.gizmoHelperApi.tweenCamera(event.face.normal);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
NgtsGizmoViewcubeFaceCube.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeFaceCube, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
555
|
+
NgtsGizmoViewcubeFaceCube.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewcubeFaceCube, isStandalone: true, selector: "ngts-gizmo-viewcube-face-cube", inputs: { font: "font", color: "color" }, usesInheritance: true, ngImport: i0, template: `
|
|
556
|
+
<ngt-mesh
|
|
557
|
+
(pointermove)="onPointerMove($any($event))"
|
|
558
|
+
(pointerout)="onPointerOut($any($event))"
|
|
559
|
+
(click)="onClick($any($event))"
|
|
560
|
+
>
|
|
561
|
+
<ngt-box-geometry />
|
|
562
|
+
<ngts-gizmo-viewcube-face-material
|
|
563
|
+
*ngFor="let i; repeat: 6"
|
|
564
|
+
[hover]="hover === i"
|
|
565
|
+
[index]="i"
|
|
566
|
+
[font]="get('font')"
|
|
567
|
+
[color]="get('color')"
|
|
568
|
+
[opacity]="get('opacity')"
|
|
569
|
+
[hoverColor]="get('hoverColor')"
|
|
570
|
+
[textColor]="get('textColor')"
|
|
571
|
+
[strokeColor]="get('strokeColor')"
|
|
572
|
+
[faces]="get('faces')"
|
|
573
|
+
/>
|
|
574
|
+
</ngt-mesh>
|
|
575
|
+
`, isInline: true, dependencies: [{ kind: "component", type: NgtsGizmoViewcubeFaceMaterial, selector: "ngts-gizmo-viewcube-face-material[hover][index]", inputs: ["index", "hover", "font", "color"] }, { kind: "directive", type: NgtRepeat, selector: "[ngFor][ngForRepeat]", inputs: ["ngForRepeat"] }] });
|
|
576
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcubeFaceCube, decorators: [{
|
|
577
|
+
type: Component,
|
|
578
|
+
args: [{
|
|
579
|
+
selector: 'ngts-gizmo-viewcube-face-cube',
|
|
580
|
+
standalone: true,
|
|
581
|
+
template: `
|
|
582
|
+
<ngt-mesh
|
|
583
|
+
(pointermove)="onPointerMove($any($event))"
|
|
584
|
+
(pointerout)="onPointerOut($any($event))"
|
|
585
|
+
(click)="onClick($any($event))"
|
|
586
|
+
>
|
|
587
|
+
<ngt-box-geometry />
|
|
588
|
+
<ngts-gizmo-viewcube-face-material
|
|
589
|
+
*ngFor="let i; repeat: 6"
|
|
590
|
+
[hover]="hover === i"
|
|
591
|
+
[index]="i"
|
|
592
|
+
[font]="get('font')"
|
|
593
|
+
[color]="get('color')"
|
|
594
|
+
[opacity]="get('opacity')"
|
|
595
|
+
[hoverColor]="get('hoverColor')"
|
|
596
|
+
[textColor]="get('textColor')"
|
|
597
|
+
[strokeColor]="get('strokeColor')"
|
|
598
|
+
[faces]="get('faces')"
|
|
599
|
+
/>
|
|
600
|
+
</ngt-mesh>
|
|
601
|
+
`,
|
|
602
|
+
imports: [NgtsGizmoViewcubeFaceMaterial, NgtRepeat],
|
|
603
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
604
|
+
}]
|
|
605
|
+
}], propDecorators: { font: [{
|
|
606
|
+
type: Input
|
|
607
|
+
}], color: [{
|
|
608
|
+
type: Input
|
|
609
|
+
}] } });
|
|
610
|
+
|
|
611
|
+
extend({ Group, AmbientLight, PointLight });
|
|
612
|
+
class NgtsGizmoViewcube extends NgtsGizmoViewcubeInputs {
|
|
613
|
+
constructor() {
|
|
614
|
+
super(...arguments);
|
|
615
|
+
this.edges = edges;
|
|
616
|
+
this.edgeDimensions = edgeDimensions;
|
|
617
|
+
this.corners = corners;
|
|
618
|
+
this.cornerDimensions = cornerDimensions;
|
|
619
|
+
this.clicked = new EventEmitter();
|
|
620
|
+
}
|
|
621
|
+
set font(font) {
|
|
622
|
+
this.set({ font });
|
|
623
|
+
}
|
|
624
|
+
set color(color) {
|
|
625
|
+
this.set({ color });
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
NgtsGizmoViewcube.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcube, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
629
|
+
NgtsGizmoViewcube.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewcube, isStandalone: true, selector: "ngts-gizmo-viewcube", inputs: { font: "font", color: "color" }, outputs: { clicked: "clicked" }, usesInheritance: true, ngImport: i0, template: `
|
|
630
|
+
<ngt-group [scale]="60">
|
|
631
|
+
<ngts-gizmo-viewcube-face-cube
|
|
632
|
+
[font]="get('font')"
|
|
633
|
+
[color]="get('color')"
|
|
634
|
+
[opacity]="get('opacity')"
|
|
635
|
+
[hoverColor]="get('hoverColor')"
|
|
636
|
+
[textColor]="get('textColor')"
|
|
637
|
+
[strokeColor]="get('strokeColor')"
|
|
638
|
+
[faces]="get('faces')"
|
|
639
|
+
[clickEmitter]="clicked"
|
|
640
|
+
/>
|
|
641
|
+
|
|
642
|
+
<ngts-gizmo-viewcube-edge-cube
|
|
643
|
+
*ngFor="let edge of edges; let i = index"
|
|
644
|
+
[position]="edge"
|
|
645
|
+
[dimensions]="edgeDimensions[i]"
|
|
646
|
+
[font]="get('font')"
|
|
647
|
+
[color]="get('color')"
|
|
648
|
+
[opacity]="get('opacity')"
|
|
649
|
+
[hoverColor]="get('hoverColor')"
|
|
650
|
+
[textColor]="get('textColor')"
|
|
651
|
+
[strokeColor]="get('strokeColor')"
|
|
652
|
+
[faces]="get('faces')"
|
|
653
|
+
[clickEmitter]="clicked"
|
|
654
|
+
/>
|
|
655
|
+
|
|
656
|
+
<ngts-gizmo-viewcube-edge-cube
|
|
657
|
+
*ngFor="let corner of corners"
|
|
658
|
+
[position]="corner"
|
|
659
|
+
[dimensions]="cornerDimensions"
|
|
660
|
+
[font]="get('font')"
|
|
661
|
+
[color]="get('color')"
|
|
662
|
+
[opacity]="get('opacity')"
|
|
663
|
+
[hoverColor]="get('hoverColor')"
|
|
664
|
+
[textColor]="get('textColor')"
|
|
665
|
+
[strokeColor]="get('strokeColor')"
|
|
666
|
+
[faces]="get('faces')"
|
|
667
|
+
[clickEmitter]="clicked"
|
|
668
|
+
/>
|
|
669
|
+
|
|
670
|
+
<ngt-ambient-light [intensity]="0.5" />
|
|
671
|
+
<ngt-point-light [position]="10" [intensity]="0.5" />
|
|
672
|
+
</ngt-group>
|
|
673
|
+
`, isInline: true, dependencies: [{ kind: "component", type: NgtsGizmoViewcubeEdgeCube, selector: "ngts-gizmo-viewcube-edge-cube[dimensions][position]", inputs: ["dimensions", "position"] }, { kind: "component", type: NgtsGizmoViewcubeFaceCube, selector: "ngts-gizmo-viewcube-face-cube", inputs: ["font", "color"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
674
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewcube, decorators: [{
|
|
675
|
+
type: Component,
|
|
676
|
+
args: [{
|
|
677
|
+
selector: 'ngts-gizmo-viewcube',
|
|
678
|
+
standalone: true,
|
|
679
|
+
template: `
|
|
680
|
+
<ngt-group [scale]="60">
|
|
681
|
+
<ngts-gizmo-viewcube-face-cube
|
|
682
|
+
[font]="get('font')"
|
|
683
|
+
[color]="get('color')"
|
|
684
|
+
[opacity]="get('opacity')"
|
|
685
|
+
[hoverColor]="get('hoverColor')"
|
|
686
|
+
[textColor]="get('textColor')"
|
|
687
|
+
[strokeColor]="get('strokeColor')"
|
|
688
|
+
[faces]="get('faces')"
|
|
689
|
+
[clickEmitter]="clicked"
|
|
690
|
+
/>
|
|
691
|
+
|
|
692
|
+
<ngts-gizmo-viewcube-edge-cube
|
|
693
|
+
*ngFor="let edge of edges; let i = index"
|
|
694
|
+
[position]="edge"
|
|
695
|
+
[dimensions]="edgeDimensions[i]"
|
|
696
|
+
[font]="get('font')"
|
|
697
|
+
[color]="get('color')"
|
|
698
|
+
[opacity]="get('opacity')"
|
|
699
|
+
[hoverColor]="get('hoverColor')"
|
|
700
|
+
[textColor]="get('textColor')"
|
|
701
|
+
[strokeColor]="get('strokeColor')"
|
|
702
|
+
[faces]="get('faces')"
|
|
703
|
+
[clickEmitter]="clicked"
|
|
704
|
+
/>
|
|
705
|
+
|
|
706
|
+
<ngts-gizmo-viewcube-edge-cube
|
|
707
|
+
*ngFor="let corner of corners"
|
|
708
|
+
[position]="corner"
|
|
709
|
+
[dimensions]="cornerDimensions"
|
|
710
|
+
[font]="get('font')"
|
|
711
|
+
[color]="get('color')"
|
|
712
|
+
[opacity]="get('opacity')"
|
|
713
|
+
[hoverColor]="get('hoverColor')"
|
|
714
|
+
[textColor]="get('textColor')"
|
|
715
|
+
[strokeColor]="get('strokeColor')"
|
|
716
|
+
[faces]="get('faces')"
|
|
717
|
+
[clickEmitter]="clicked"
|
|
718
|
+
/>
|
|
719
|
+
|
|
720
|
+
<ngt-ambient-light [intensity]="0.5" />
|
|
721
|
+
<ngt-point-light [position]="10" [intensity]="0.5" />
|
|
722
|
+
</ngt-group>
|
|
723
|
+
`,
|
|
724
|
+
imports: [NgtsGizmoViewcubeEdgeCube, NgtsGizmoViewcubeFaceCube, NgFor],
|
|
725
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
726
|
+
}]
|
|
727
|
+
}], propDecorators: { font: [{
|
|
728
|
+
type: Input
|
|
729
|
+
}], color: [{
|
|
730
|
+
type: Input
|
|
731
|
+
}], clicked: [{
|
|
732
|
+
type: Output
|
|
733
|
+
}] } });
|
|
734
|
+
|
|
735
|
+
extend({ Group, Mesh, BoxGeometry, MeshBasicMaterial, Sprite, SpriteMaterial });
|
|
736
|
+
class NgtsGizmoViewportAxis extends NgtRxStore {
|
|
737
|
+
set color(color) {
|
|
738
|
+
this.set({ color });
|
|
739
|
+
}
|
|
740
|
+
set rotation(rotation) {
|
|
741
|
+
this.set({ rotation });
|
|
742
|
+
}
|
|
743
|
+
set scale(scale) {
|
|
744
|
+
this.set({ scale: scale === undefined ? this.get('scale') : scale });
|
|
745
|
+
}
|
|
746
|
+
initialize() {
|
|
747
|
+
super.initialize();
|
|
748
|
+
this.set({ scale: [0.8, 0.05, 0.05] });
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
NgtsGizmoViewportAxis.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewportAxis, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
752
|
+
NgtsGizmoViewportAxis.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewportAxis, isStandalone: true, selector: "ngts-gizmo-viewport-axis[color][rotation]", inputs: { color: "color", rotation: "rotation", scale: "scale" }, usesInheritance: true, ngImport: i0, template: `
|
|
753
|
+
<ngt-group [rotation]="get('rotation')">
|
|
754
|
+
<ngt-mesh [position]="[0.4, 0, 0]">
|
|
755
|
+
<ngt-box-geometry *args="get('scale')" />
|
|
756
|
+
<ngt-mesh-basic-material [color]="get('color')" [toneMapped]="false" />
|
|
757
|
+
</ngt-mesh>
|
|
758
|
+
</ngt-group>
|
|
759
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
|
|
760
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewportAxis, decorators: [{
|
|
761
|
+
type: Component,
|
|
762
|
+
args: [{
|
|
763
|
+
selector: 'ngts-gizmo-viewport-axis[color][rotation]',
|
|
764
|
+
standalone: true,
|
|
765
|
+
template: `
|
|
766
|
+
<ngt-group [rotation]="get('rotation')">
|
|
767
|
+
<ngt-mesh [position]="[0.4, 0, 0]">
|
|
768
|
+
<ngt-box-geometry *args="get('scale')" />
|
|
769
|
+
<ngt-mesh-basic-material [color]="get('color')" [toneMapped]="false" />
|
|
770
|
+
</ngt-mesh>
|
|
771
|
+
</ngt-group>
|
|
772
|
+
`,
|
|
773
|
+
imports: [NgtArgs],
|
|
774
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
775
|
+
}]
|
|
776
|
+
}], propDecorators: { color: [{
|
|
777
|
+
type: Input
|
|
778
|
+
}], rotation: [{
|
|
779
|
+
type: Input
|
|
780
|
+
}], scale: [{
|
|
781
|
+
type: Input
|
|
782
|
+
}] } });
|
|
783
|
+
class NgtsGizmoViewportAxisHead extends NgtRxStore {
|
|
784
|
+
constructor() {
|
|
785
|
+
super(...arguments);
|
|
786
|
+
this.document = inject(DOCUMENT);
|
|
787
|
+
this.store = inject(NgtStore);
|
|
788
|
+
this.gl = this.store.get('gl');
|
|
789
|
+
}
|
|
790
|
+
set arcStyle(arcStyle) {
|
|
791
|
+
this.set({ arcStyle });
|
|
792
|
+
}
|
|
793
|
+
set label(label) {
|
|
794
|
+
this.set({ label });
|
|
795
|
+
}
|
|
796
|
+
set labelColor(labelColor) {
|
|
797
|
+
this.set({ labelColor });
|
|
798
|
+
}
|
|
799
|
+
set axisHeadScale(axisHeadScale) {
|
|
800
|
+
this.set({ axisHeadScale });
|
|
801
|
+
}
|
|
802
|
+
set disabled(disabled) {
|
|
803
|
+
this.set({ disabled });
|
|
804
|
+
}
|
|
805
|
+
set font(font) {
|
|
806
|
+
this.set({ font });
|
|
807
|
+
}
|
|
808
|
+
set clickEmitter(clickEmitter) {
|
|
809
|
+
this.set({ clickEmitter });
|
|
810
|
+
}
|
|
811
|
+
initialize() {
|
|
812
|
+
super.initialize();
|
|
813
|
+
this.set({ axisHeadScale: 1, active: false });
|
|
814
|
+
this.connect('texture', combineLatest([
|
|
815
|
+
this.select('arcStyle'),
|
|
816
|
+
this.select('labelColor'),
|
|
817
|
+
this.select('font'),
|
|
818
|
+
this.select('label').pipe(startWithUndefined()),
|
|
819
|
+
]).pipe(map(([arcStyle, labelColor, font, label]) => {
|
|
820
|
+
const canvas = this.document.createElement('canvas');
|
|
821
|
+
canvas.width = 64;
|
|
822
|
+
canvas.height = 64;
|
|
823
|
+
const context = canvas.getContext('2d');
|
|
824
|
+
context.beginPath();
|
|
825
|
+
context.arc(32, 32, 16, 0, 2 * Math.PI);
|
|
826
|
+
context.closePath();
|
|
827
|
+
context.fillStyle = arcStyle;
|
|
828
|
+
context.fill();
|
|
829
|
+
if (label) {
|
|
830
|
+
context.font = font;
|
|
831
|
+
context.textAlign = 'center';
|
|
832
|
+
context.fillStyle = labelColor;
|
|
833
|
+
context.fillText(label, 32, 41);
|
|
834
|
+
}
|
|
835
|
+
return new CanvasTexture(canvas);
|
|
836
|
+
})));
|
|
837
|
+
this.connect('scale', combineLatest([
|
|
838
|
+
this.select('active'),
|
|
839
|
+
this.select('axisHeadScale'),
|
|
840
|
+
this.select('label').pipe(startWithUndefined()),
|
|
841
|
+
]).pipe(map(([active, axisHeadScale, label]) => (label ? 1 : 0.75) * (active ? 1.2 : 1) * axisHeadScale)));
|
|
842
|
+
}
|
|
843
|
+
onPointerOver(event) {
|
|
844
|
+
if (!this.get('disabled')) {
|
|
845
|
+
event.stopPropagation();
|
|
846
|
+
this.set({ active: true });
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
onPointerOut(event) {
|
|
850
|
+
if (!this.get('disabled')) {
|
|
851
|
+
if (this.get('clickEmitter')?.observed) {
|
|
852
|
+
this.get('clickEmitter').emit(event);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
event.stopPropagation();
|
|
856
|
+
this.set({ active: false });
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
NgtsGizmoViewportAxisHead.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewportAxisHead, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
862
|
+
NgtsGizmoViewportAxisHead.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewportAxisHead, isStandalone: true, selector: "ngts-gizmo-viewport-axis-head", inputs: { arcStyle: "arcStyle", label: "label", labelColor: "labelColor", axisHeadScale: "axisHeadScale", disabled: "disabled", font: "font", clickEmitter: "clickEmitter" }, usesInheritance: true, ngImport: i0, template: `
|
|
863
|
+
<ngt-sprite
|
|
864
|
+
ngtCompound
|
|
865
|
+
[scale]="get('scale')"
|
|
866
|
+
(pointerover)="onPointerOver($any($event))"
|
|
867
|
+
(pointerout)="onPointerOut($any($event))"
|
|
868
|
+
>
|
|
869
|
+
<ngt-sprite-material
|
|
870
|
+
[map]="get('texture')"
|
|
871
|
+
[opacity]="get('label') ? 1 : 0.75"
|
|
872
|
+
[alphaTest]="0.3"
|
|
873
|
+
[toneMapped]="false"
|
|
874
|
+
>
|
|
875
|
+
<ngt-value [rawValue]="gl.outputEncoding" attach="map.encoding" />
|
|
876
|
+
<ngt-value [rawValue]="gl.capabilities.getMaxAnisotropy() || 1" attach="map.anisotropy" />
|
|
877
|
+
</ngt-sprite-material>
|
|
878
|
+
</ngt-sprite>
|
|
879
|
+
`, isInline: true });
|
|
880
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewportAxisHead, decorators: [{
|
|
881
|
+
type: Component,
|
|
882
|
+
args: [{
|
|
883
|
+
selector: 'ngts-gizmo-viewport-axis-head',
|
|
884
|
+
standalone: true,
|
|
885
|
+
template: `
|
|
886
|
+
<ngt-sprite
|
|
887
|
+
ngtCompound
|
|
888
|
+
[scale]="get('scale')"
|
|
889
|
+
(pointerover)="onPointerOver($any($event))"
|
|
890
|
+
(pointerout)="onPointerOut($any($event))"
|
|
891
|
+
>
|
|
892
|
+
<ngt-sprite-material
|
|
893
|
+
[map]="get('texture')"
|
|
894
|
+
[opacity]="get('label') ? 1 : 0.75"
|
|
895
|
+
[alphaTest]="0.3"
|
|
896
|
+
[toneMapped]="false"
|
|
897
|
+
>
|
|
898
|
+
<ngt-value [rawValue]="gl.outputEncoding" attach="map.encoding" />
|
|
899
|
+
<ngt-value [rawValue]="gl.capabilities.getMaxAnisotropy() || 1" attach="map.anisotropy" />
|
|
900
|
+
</ngt-sprite-material>
|
|
901
|
+
</ngt-sprite>
|
|
902
|
+
`,
|
|
903
|
+
imports: [NgtArgs],
|
|
904
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
905
|
+
}]
|
|
906
|
+
}], propDecorators: { arcStyle: [{
|
|
907
|
+
type: Input
|
|
908
|
+
}], label: [{
|
|
909
|
+
type: Input
|
|
910
|
+
}], labelColor: [{
|
|
911
|
+
type: Input
|
|
912
|
+
}], axisHeadScale: [{
|
|
913
|
+
type: Input
|
|
914
|
+
}], disabled: [{
|
|
915
|
+
type: Input
|
|
916
|
+
}], font: [{
|
|
917
|
+
type: Input
|
|
918
|
+
}], clickEmitter: [{
|
|
919
|
+
type: Input
|
|
920
|
+
}] } });
|
|
921
|
+
|
|
922
|
+
extend({ Group, AmbientLight, PointLight });
|
|
923
|
+
class NgtsGizmoViewport extends NgtRxStore {
|
|
924
|
+
constructor() {
|
|
925
|
+
super(...arguments);
|
|
926
|
+
this.gizmoHelperApi = inject(NGTS_GIZMO_HELPER_API);
|
|
927
|
+
this.Math = Math;
|
|
928
|
+
this.clicked = new EventEmitter();
|
|
929
|
+
}
|
|
930
|
+
set axisColors(axisColors) {
|
|
931
|
+
this.set({ axisColors });
|
|
932
|
+
}
|
|
933
|
+
set axisScale(axisScale) {
|
|
934
|
+
this.set({ axisScale });
|
|
935
|
+
}
|
|
936
|
+
set labels(labels) {
|
|
937
|
+
this.set({ labels });
|
|
938
|
+
}
|
|
939
|
+
set axisHeadScale(axisHeadScale) {
|
|
940
|
+
this.set({ axisHeadScale });
|
|
941
|
+
}
|
|
942
|
+
set labelColor(labelColor) {
|
|
943
|
+
this.set({ labelColor });
|
|
944
|
+
}
|
|
945
|
+
set hideNegativeAxes(hideNegativeAxes) {
|
|
946
|
+
this.set({ hideNegativeAxes });
|
|
947
|
+
}
|
|
948
|
+
set hideAxisHeads(hideAxisHeads) {
|
|
949
|
+
this.set({ hideAxisHeads });
|
|
950
|
+
}
|
|
951
|
+
set disabled(disabled) {
|
|
952
|
+
this.set({ disabled });
|
|
953
|
+
}
|
|
954
|
+
set font(font) {
|
|
955
|
+
this.set({ font });
|
|
956
|
+
}
|
|
957
|
+
initialize() {
|
|
958
|
+
super.initialize();
|
|
959
|
+
this.set({
|
|
960
|
+
font: '18px Inter var, Arial, sans-serif',
|
|
961
|
+
axisColors: ['#ff2060', '#20df80', '#2080ff'],
|
|
962
|
+
axisHeadScale: 1,
|
|
963
|
+
labels: ['X', 'Y', 'Z'],
|
|
964
|
+
labelColor: '#000',
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
onPointerDown(event) {
|
|
968
|
+
if (!this.get('disabled')) {
|
|
969
|
+
event.stopPropagation();
|
|
970
|
+
this.gizmoHelperApi.tweenCamera(event.object.position);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
NgtsGizmoViewport.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewport, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
975
|
+
NgtsGizmoViewport.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsGizmoViewport, isStandalone: true, selector: "ngts-gizmo-viewport", inputs: { axisColors: "axisColors", axisScale: "axisScale", labels: "labels", axisHeadScale: "axisHeadScale", labelColor: "labelColor", hideNegativeAxes: "hideNegativeAxes", hideAxisHeads: "hideAxisHeads", disabled: "disabled", font: "font" }, outputs: { clicked: "clicked" }, usesInheritance: true, ngImport: i0, template: `
|
|
976
|
+
<ngt-group ngtCompound [scale]="40">
|
|
977
|
+
<ngts-gizmo-viewport-axis
|
|
978
|
+
[color]="get('axisColors')[0]"
|
|
979
|
+
[rotation]="[0, 0, 0]"
|
|
980
|
+
[scale]="get('axisScale')"
|
|
981
|
+
></ngts-gizmo-viewport-axis>
|
|
982
|
+
<ngts-gizmo-viewport-axis
|
|
983
|
+
[color]="get('axisColors')[1]"
|
|
984
|
+
[rotation]="[0, 0, Math.PI / 2]"
|
|
985
|
+
[scale]="get('axisScale')"
|
|
986
|
+
></ngts-gizmo-viewport-axis>
|
|
987
|
+
<ngts-gizmo-viewport-axis
|
|
988
|
+
[color]="get('axisColors')[2]"
|
|
989
|
+
[rotation]="[0, -Math.PI / 2, 0]"
|
|
990
|
+
[scale]="get('axisScale')"
|
|
991
|
+
></ngts-gizmo-viewport-axis>
|
|
992
|
+
<ng-container *ngIf="!get('hideAxisHeads')">
|
|
993
|
+
<ngts-gizmo-viewport-axis-head
|
|
994
|
+
[arcStyle]="get('axisColors')[0]"
|
|
995
|
+
[position]="[1, 0, 0]"
|
|
996
|
+
[label]="get('labels')[0]"
|
|
997
|
+
[font]="get('font')"
|
|
998
|
+
[disabled]="get('disabled')"
|
|
999
|
+
[labelColor]="get('labelColor')"
|
|
1000
|
+
[clickEmitter]="clicked"
|
|
1001
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1002
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1003
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1004
|
+
<ngts-gizmo-viewport-axis-head
|
|
1005
|
+
[arcStyle]="get('axisColors')[1]"
|
|
1006
|
+
[position]="[0, 1, 0]"
|
|
1007
|
+
[label]="get('labels')[1]"
|
|
1008
|
+
[font]="get('font')"
|
|
1009
|
+
[disabled]="get('disabled')"
|
|
1010
|
+
[labelColor]="get('labelColor')"
|
|
1011
|
+
[clickEmitter]="clicked"
|
|
1012
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1013
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1014
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1015
|
+
<ngts-gizmo-viewport-axis-head
|
|
1016
|
+
[arcStyle]="get('axisColors')[2]"
|
|
1017
|
+
[position]="[0, 0, 1]"
|
|
1018
|
+
[label]="get('labels')[2]"
|
|
1019
|
+
[font]="get('font')"
|
|
1020
|
+
[disabled]="get('disabled')"
|
|
1021
|
+
[labelColor]="get('labelColor')"
|
|
1022
|
+
[clickEmitter]="clicked"
|
|
1023
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1024
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1025
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1026
|
+
<ng-container *ngIf="!get('hideNegativeAxes')">
|
|
1027
|
+
<ngts-gizmo-viewport-axis-head
|
|
1028
|
+
[arcStyle]="get('axisColors')[0]"
|
|
1029
|
+
[position]="[-1, 0, 0]"
|
|
1030
|
+
[font]="get('font')"
|
|
1031
|
+
[disabled]="get('disabled')"
|
|
1032
|
+
[labelColor]="get('labelColor')"
|
|
1033
|
+
[clickEmitter]="clicked"
|
|
1034
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1035
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1036
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1037
|
+
<ngts-gizmo-viewport-axis-head
|
|
1038
|
+
[arcStyle]="get('axisColors')[1]"
|
|
1039
|
+
[position]="[0, -1, 0]"
|
|
1040
|
+
[font]="get('font')"
|
|
1041
|
+
[disabled]="get('disabled')"
|
|
1042
|
+
[labelColor]="get('labelColor')"
|
|
1043
|
+
[clickEmitter]="clicked"
|
|
1044
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1045
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1046
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1047
|
+
<ngts-gizmo-viewport-axis-head
|
|
1048
|
+
[arcStyle]="get('axisColors')[2]"
|
|
1049
|
+
[position]="[0, 0, -1]"
|
|
1050
|
+
[font]="get('font')"
|
|
1051
|
+
[disabled]="get('disabled')"
|
|
1052
|
+
[labelColor]="get('labelColor')"
|
|
1053
|
+
[clickEmitter]="clicked"
|
|
1054
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1055
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1056
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1057
|
+
</ng-container>
|
|
1058
|
+
</ng-container>
|
|
1059
|
+
<ngt-ambient-light intensity="0.5"></ngt-ambient-light>
|
|
1060
|
+
<ngt-point-light position="10" intensity="0.5"></ngt-point-light>
|
|
1061
|
+
</ngt-group>
|
|
1062
|
+
`, isInline: true, dependencies: [{ kind: "component", type: NgtsGizmoViewportAxis, selector: "ngts-gizmo-viewport-axis[color][rotation]", inputs: ["color", "rotation", "scale"] }, { kind: "component", type: NgtsGizmoViewportAxisHead, selector: "ngts-gizmo-viewport-axis-head", inputs: ["arcStyle", "label", "labelColor", "axisHeadScale", "disabled", "font", "clickEmitter"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
1063
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsGizmoViewport, decorators: [{
|
|
1064
|
+
type: Component,
|
|
1065
|
+
args: [{
|
|
1066
|
+
selector: 'ngts-gizmo-viewport',
|
|
1067
|
+
standalone: true,
|
|
1068
|
+
template: `
|
|
1069
|
+
<ngt-group ngtCompound [scale]="40">
|
|
1070
|
+
<ngts-gizmo-viewport-axis
|
|
1071
|
+
[color]="get('axisColors')[0]"
|
|
1072
|
+
[rotation]="[0, 0, 0]"
|
|
1073
|
+
[scale]="get('axisScale')"
|
|
1074
|
+
></ngts-gizmo-viewport-axis>
|
|
1075
|
+
<ngts-gizmo-viewport-axis
|
|
1076
|
+
[color]="get('axisColors')[1]"
|
|
1077
|
+
[rotation]="[0, 0, Math.PI / 2]"
|
|
1078
|
+
[scale]="get('axisScale')"
|
|
1079
|
+
></ngts-gizmo-viewport-axis>
|
|
1080
|
+
<ngts-gizmo-viewport-axis
|
|
1081
|
+
[color]="get('axisColors')[2]"
|
|
1082
|
+
[rotation]="[0, -Math.PI / 2, 0]"
|
|
1083
|
+
[scale]="get('axisScale')"
|
|
1084
|
+
></ngts-gizmo-viewport-axis>
|
|
1085
|
+
<ng-container *ngIf="!get('hideAxisHeads')">
|
|
1086
|
+
<ngts-gizmo-viewport-axis-head
|
|
1087
|
+
[arcStyle]="get('axisColors')[0]"
|
|
1088
|
+
[position]="[1, 0, 0]"
|
|
1089
|
+
[label]="get('labels')[0]"
|
|
1090
|
+
[font]="get('font')"
|
|
1091
|
+
[disabled]="get('disabled')"
|
|
1092
|
+
[labelColor]="get('labelColor')"
|
|
1093
|
+
[clickEmitter]="clicked"
|
|
1094
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1095
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1096
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1097
|
+
<ngts-gizmo-viewport-axis-head
|
|
1098
|
+
[arcStyle]="get('axisColors')[1]"
|
|
1099
|
+
[position]="[0, 1, 0]"
|
|
1100
|
+
[label]="get('labels')[1]"
|
|
1101
|
+
[font]="get('font')"
|
|
1102
|
+
[disabled]="get('disabled')"
|
|
1103
|
+
[labelColor]="get('labelColor')"
|
|
1104
|
+
[clickEmitter]="clicked"
|
|
1105
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1106
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1107
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1108
|
+
<ngts-gizmo-viewport-axis-head
|
|
1109
|
+
[arcStyle]="get('axisColors')[2]"
|
|
1110
|
+
[position]="[0, 0, 1]"
|
|
1111
|
+
[label]="get('labels')[2]"
|
|
1112
|
+
[font]="get('font')"
|
|
1113
|
+
[disabled]="get('disabled')"
|
|
1114
|
+
[labelColor]="get('labelColor')"
|
|
1115
|
+
[clickEmitter]="clicked"
|
|
1116
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1117
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1118
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1119
|
+
<ng-container *ngIf="!get('hideNegativeAxes')">
|
|
1120
|
+
<ngts-gizmo-viewport-axis-head
|
|
1121
|
+
[arcStyle]="get('axisColors')[0]"
|
|
1122
|
+
[position]="[-1, 0, 0]"
|
|
1123
|
+
[font]="get('font')"
|
|
1124
|
+
[disabled]="get('disabled')"
|
|
1125
|
+
[labelColor]="get('labelColor')"
|
|
1126
|
+
[clickEmitter]="clicked"
|
|
1127
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1128
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1129
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1130
|
+
<ngts-gizmo-viewport-axis-head
|
|
1131
|
+
[arcStyle]="get('axisColors')[1]"
|
|
1132
|
+
[position]="[0, -1, 0]"
|
|
1133
|
+
[font]="get('font')"
|
|
1134
|
+
[disabled]="get('disabled')"
|
|
1135
|
+
[labelColor]="get('labelColor')"
|
|
1136
|
+
[clickEmitter]="clicked"
|
|
1137
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1138
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1139
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1140
|
+
<ngts-gizmo-viewport-axis-head
|
|
1141
|
+
[arcStyle]="get('axisColors')[2]"
|
|
1142
|
+
[position]="[0, 0, -1]"
|
|
1143
|
+
[font]="get('font')"
|
|
1144
|
+
[disabled]="get('disabled')"
|
|
1145
|
+
[labelColor]="get('labelColor')"
|
|
1146
|
+
[clickEmitter]="clicked"
|
|
1147
|
+
[axisHeadScale]="get('axisHeadScale')"
|
|
1148
|
+
(pointerdown)="onPointerDown($any($event))"
|
|
1149
|
+
></ngts-gizmo-viewport-axis-head>
|
|
1150
|
+
</ng-container>
|
|
1151
|
+
</ng-container>
|
|
1152
|
+
<ngt-ambient-light intensity="0.5"></ngt-ambient-light>
|
|
1153
|
+
<ngt-point-light position="10" intensity="0.5"></ngt-point-light>
|
|
1154
|
+
</ngt-group>
|
|
1155
|
+
`,
|
|
1156
|
+
imports: [NgtsGizmoViewportAxis, NgtsGizmoViewportAxisHead, NgIf],
|
|
1157
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
1158
|
+
}]
|
|
1159
|
+
}], propDecorators: { axisColors: [{
|
|
1160
|
+
type: Input
|
|
1161
|
+
}], axisScale: [{
|
|
1162
|
+
type: Input
|
|
1163
|
+
}], labels: [{
|
|
1164
|
+
type: Input
|
|
1165
|
+
}], axisHeadScale: [{
|
|
1166
|
+
type: Input
|
|
1167
|
+
}], labelColor: [{
|
|
1168
|
+
type: Input
|
|
1169
|
+
}], hideNegativeAxes: [{
|
|
1170
|
+
type: Input
|
|
1171
|
+
}], hideAxisHeads: [{
|
|
1172
|
+
type: Input
|
|
1173
|
+
}], disabled: [{
|
|
1174
|
+
type: Input
|
|
1175
|
+
}], font: [{
|
|
1176
|
+
type: Input
|
|
1177
|
+
}], clicked: [{
|
|
1178
|
+
type: Output
|
|
1179
|
+
}] } });
|
|
1180
|
+
|
|
1181
|
+
extend({ Mesh, TextGeometry });
|
|
1182
|
+
class NgtsText3D extends NgtRxStore {
|
|
1183
|
+
constructor() {
|
|
1184
|
+
super(...arguments);
|
|
1185
|
+
this.font$ = this.select('font').pipe(switchMap((font) => {
|
|
1186
|
+
if (typeof font === 'string')
|
|
1187
|
+
return fetch(font).then((res) => res.json());
|
|
1188
|
+
return of(font);
|
|
1189
|
+
}), map((fontData) => new FontLoader().parse(fontData)));
|
|
1190
|
+
this.geometryArgs$ = combineLatest([
|
|
1191
|
+
this.font$,
|
|
1192
|
+
this.select('text'),
|
|
1193
|
+
this.select('size'),
|
|
1194
|
+
this.select('height'),
|
|
1195
|
+
this.select('bevelThickness'),
|
|
1196
|
+
this.select('bevelSize'),
|
|
1197
|
+
this.select('bevelEnabled'),
|
|
1198
|
+
this.select('bevelSegments'),
|
|
1199
|
+
this.select('bevelOffset'),
|
|
1200
|
+
this.select('curveSegments'),
|
|
1201
|
+
this.select('letterSpacing'),
|
|
1202
|
+
this.select('lineHeight'),
|
|
1203
|
+
]).pipe(map(([font, text, size, height, bevelThickness, bevelSize, bevelEnabled, bevelSegments, bevelOffset, curveSegments, letterSpacing, lineHeight,]) => [
|
|
1204
|
+
text,
|
|
1205
|
+
{
|
|
1206
|
+
font,
|
|
1207
|
+
size,
|
|
1208
|
+
height,
|
|
1209
|
+
bevelThickness,
|
|
1210
|
+
bevelSize,
|
|
1211
|
+
bevelSegments,
|
|
1212
|
+
bevelEnabled,
|
|
1213
|
+
bevelOffset,
|
|
1214
|
+
curveSegments,
|
|
1215
|
+
letterSpacing,
|
|
1216
|
+
lineHeight,
|
|
1217
|
+
},
|
|
1218
|
+
]));
|
|
1219
|
+
}
|
|
1220
|
+
set font(font) {
|
|
1221
|
+
this.set({ font });
|
|
1222
|
+
}
|
|
1223
|
+
set text(text) {
|
|
1224
|
+
this.set({ text });
|
|
1225
|
+
}
|
|
1226
|
+
set bevelEnabled(bevelEnabled) {
|
|
1227
|
+
this.set({ bevelEnabled });
|
|
1228
|
+
}
|
|
1229
|
+
set bevelOffset(bevelOffset) {
|
|
1230
|
+
this.set({ bevelOffset });
|
|
1231
|
+
}
|
|
1232
|
+
set bevelSize(bevelSize) {
|
|
1233
|
+
this.set({ bevelSize });
|
|
1234
|
+
}
|
|
1235
|
+
set bevelThickness(bevelThickness) {
|
|
1236
|
+
this.set({ bevelThickness });
|
|
1237
|
+
}
|
|
1238
|
+
set curveSegments(curveSegments) {
|
|
1239
|
+
this.set({ curveSegments });
|
|
1240
|
+
}
|
|
1241
|
+
set bevelSegments(bevelSegments) {
|
|
1242
|
+
this.set({ bevelSegments });
|
|
1243
|
+
}
|
|
1244
|
+
set height(height) {
|
|
1245
|
+
this.set({ height });
|
|
1246
|
+
}
|
|
1247
|
+
set size(size) {
|
|
1248
|
+
this.set({ size });
|
|
1249
|
+
}
|
|
1250
|
+
set lineHeight(lineHeight) {
|
|
1251
|
+
this.set({ lineHeight });
|
|
1252
|
+
}
|
|
1253
|
+
set letterSpacing(letterSpacing) {
|
|
1254
|
+
this.set({ letterSpacing });
|
|
1255
|
+
}
|
|
1256
|
+
initialize() {
|
|
1257
|
+
super.initialize();
|
|
1258
|
+
this.set({
|
|
1259
|
+
letterSpacing: 0,
|
|
1260
|
+
lineHeight: 1,
|
|
1261
|
+
size: 1,
|
|
1262
|
+
height: 0.2,
|
|
1263
|
+
bevelThickness: 0.1,
|
|
1264
|
+
bevelSize: 0.01,
|
|
1265
|
+
bevelEnabled: false,
|
|
1266
|
+
bevelOffset: 0,
|
|
1267
|
+
bevelSegments: 4,
|
|
1268
|
+
curveSegments: 8,
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
NgtsText3D.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsText3D, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1273
|
+
NgtsText3D.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsText3D, isStandalone: true, selector: "ngts-text-3d[font]", inputs: { font: "font", text: "text", bevelEnabled: "bevelEnabled", bevelOffset: "bevelOffset", bevelSize: "bevelSize", bevelThickness: "bevelThickness", curveSegments: "curveSegments", bevelSegments: "bevelSegments", height: "height", size: "size", lineHeight: "lineHeight", letterSpacing: "letterSpacing" }, usesInheritance: true, ngImport: i0, template: `
|
|
1274
|
+
<ngt-mesh ngtCompound>
|
|
1275
|
+
<ngt-text-geometry *args="geometryArgs$ | ngtPush : null" />
|
|
1276
|
+
<ng-content />
|
|
1277
|
+
</ngt-mesh>
|
|
1278
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }, { kind: "pipe", type: NgtPush, name: "ngtPush" }] });
|
|
1279
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsText3D, decorators: [{
|
|
1280
|
+
type: Component,
|
|
1281
|
+
args: [{
|
|
1282
|
+
selector: 'ngts-text-3d[font]',
|
|
1283
|
+
standalone: true,
|
|
1284
|
+
template: `
|
|
1285
|
+
<ngt-mesh ngtCompound>
|
|
1286
|
+
<ngt-text-geometry *args="geometryArgs$ | ngtPush : null" />
|
|
1287
|
+
<ng-content />
|
|
1288
|
+
</ngt-mesh>
|
|
1289
|
+
`,
|
|
1290
|
+
imports: [NgtArgs, NgtPush],
|
|
1291
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
1292
|
+
}]
|
|
1293
|
+
}], propDecorators: { font: [{
|
|
1294
|
+
type: Input
|
|
1295
|
+
}], text: [{
|
|
1296
|
+
type: Input
|
|
1297
|
+
}], bevelEnabled: [{
|
|
1298
|
+
type: Input
|
|
1299
|
+
}], bevelOffset: [{
|
|
1300
|
+
type: Input
|
|
1301
|
+
}], bevelSize: [{
|
|
1302
|
+
type: Input
|
|
1303
|
+
}], bevelThickness: [{
|
|
1304
|
+
type: Input
|
|
1305
|
+
}], curveSegments: [{
|
|
1306
|
+
type: Input
|
|
1307
|
+
}], bevelSegments: [{
|
|
1308
|
+
type: Input
|
|
1309
|
+
}], height: [{
|
|
1310
|
+
type: Input
|
|
1311
|
+
}], size: [{
|
|
1312
|
+
type: Input
|
|
1313
|
+
}], lineHeight: [{
|
|
1314
|
+
type: Input
|
|
1315
|
+
}], letterSpacing: [{
|
|
1316
|
+
type: Input
|
|
1317
|
+
}] } });
|
|
1318
|
+
|
|
1319
|
+
class NgtsText extends NgtRxStore {
|
|
1320
|
+
constructor() {
|
|
1321
|
+
super(...arguments);
|
|
1322
|
+
this.textRef = injectNgtRef();
|
|
1323
|
+
this.sync = new EventEmitter();
|
|
1324
|
+
this.store = inject(NgtStore);
|
|
1325
|
+
this.troikaText = new Text();
|
|
1326
|
+
}
|
|
1327
|
+
set text(text) {
|
|
1328
|
+
this.set({ text });
|
|
1329
|
+
}
|
|
1330
|
+
set characters(characters) {
|
|
1331
|
+
this.set({ characters });
|
|
1332
|
+
}
|
|
1333
|
+
set font(font) {
|
|
1334
|
+
this.set({ font });
|
|
1335
|
+
}
|
|
1336
|
+
set anchorX(anchorX) {
|
|
1337
|
+
this.set({ anchorX });
|
|
1338
|
+
}
|
|
1339
|
+
set anchorY(anchorY) {
|
|
1340
|
+
this.set({ anchorY });
|
|
1341
|
+
}
|
|
1342
|
+
initialize() {
|
|
1343
|
+
super.initialize();
|
|
1344
|
+
this.set({ anchorX: 'center', anchorY: 'middle', text: '' });
|
|
1345
|
+
}
|
|
1346
|
+
ngOnInit() {
|
|
1347
|
+
if (!this.textRef.nativeElement)
|
|
1348
|
+
this.textRef.nativeElement = this.troikaText;
|
|
1349
|
+
this.preloadFont();
|
|
1350
|
+
this.syncText();
|
|
1351
|
+
}
|
|
1352
|
+
ngOnDestroy() {
|
|
1353
|
+
this.troikaText.dispose();
|
|
1354
|
+
super.ngOnDestroy();
|
|
1355
|
+
}
|
|
1356
|
+
preloadFont() {
|
|
1357
|
+
const { font, characters } = this.get();
|
|
1358
|
+
if (font && characters) {
|
|
1359
|
+
preloadFont({ font, characters });
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
syncText() {
|
|
1363
|
+
this.hold(this.select(), () => {
|
|
1364
|
+
const invalidate = this.store.get('invalidate');
|
|
1365
|
+
this.troikaText.sync(() => {
|
|
1366
|
+
invalidate();
|
|
1367
|
+
if (this.sync.observed)
|
|
1368
|
+
this.sync.next(this.troikaText);
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
NgtsText.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsText, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1374
|
+
NgtsText.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsText, isStandalone: true, selector: "ngts-text[text]", inputs: { textRef: "textRef", text: "text", characters: "characters", font: "font", anchorX: "anchorX", anchorY: "anchorY" }, outputs: { sync: "sync" }, providers: [RxActionFactory], usesInheritance: true, ngImport: i0, template: `
|
|
1375
|
+
<ngt-primitive
|
|
1376
|
+
ngtCompound
|
|
1377
|
+
*args="[textRef.nativeElement]"
|
|
1378
|
+
[text]="get('text')"
|
|
1379
|
+
[anchorX]="get('anchorX')"
|
|
1380
|
+
[anchorY]="get('anchorY')"
|
|
1381
|
+
[font]="get('font')"
|
|
1382
|
+
>
|
|
1383
|
+
<ng-content />
|
|
1384
|
+
</ngt-primitive>
|
|
1385
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgtArgs, selector: "[args]", inputs: ["args"] }] });
|
|
1386
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsText, decorators: [{
|
|
1387
|
+
type: Component,
|
|
1388
|
+
args: [{
|
|
1389
|
+
selector: 'ngts-text[text]',
|
|
1390
|
+
standalone: true,
|
|
1391
|
+
template: `
|
|
1392
|
+
<ngt-primitive
|
|
1393
|
+
ngtCompound
|
|
1394
|
+
*args="[textRef.nativeElement]"
|
|
1395
|
+
[text]="get('text')"
|
|
1396
|
+
[anchorX]="get('anchorX')"
|
|
1397
|
+
[anchorY]="get('anchorY')"
|
|
1398
|
+
[font]="get('font')"
|
|
1399
|
+
>
|
|
1400
|
+
<ng-content />
|
|
1401
|
+
</ngt-primitive>
|
|
1402
|
+
`,
|
|
1403
|
+
imports: [NgtArgs],
|
|
1404
|
+
providers: [RxActionFactory],
|
|
1405
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
1406
|
+
}]
|
|
1407
|
+
}], propDecorators: { textRef: [{
|
|
1408
|
+
type: Input
|
|
1409
|
+
}], text: [{
|
|
1410
|
+
type: Input
|
|
1411
|
+
}], characters: [{
|
|
1412
|
+
type: Input
|
|
1413
|
+
}], font: [{
|
|
1414
|
+
type: Input
|
|
1415
|
+
}], anchorX: [{
|
|
1416
|
+
type: Input
|
|
1417
|
+
}], anchorY: [{
|
|
1418
|
+
type: Input
|
|
1419
|
+
}], sync: [{
|
|
1420
|
+
type: Output
|
|
1421
|
+
}] } });
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Generated bundle index. Do not edit.
|
|
1425
|
+
*/
|
|
1426
|
+
|
|
1427
|
+
export { NGTS_GIZMO_HELPER_API, NgtsBillboard, NgtsGizmoHelper, NgtsGizmoHelperContent, NgtsGizmoViewcube, NgtsGizmoViewport, NgtsText, NgtsText3D };
|
|
1428
|
+
//# sourceMappingURL=angular-three-soba-abstractions.mjs.map
|