Skip to content

Commit 06713f4

Browse files
committed
docs: adjust starbucks example because pivot controls is not working correctly
1 parent 0091a6f commit 06713f4

File tree

1 file changed

+21
-37
lines changed

1 file changed

+21
-37
lines changed

apps/kitchen-sink/src/app/soba/starbucks/experience.ts

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
ChangeDetectionStrategy,
3-
Component,
4-
CUSTOM_ELEMENTS_SCHEMA,
5-
effect,
6-
Signal,
7-
signal,
8-
viewChild,
9-
} from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, Signal, signal } from '@angular/core';
102
import { NgtArgs, NgtEuler, NgtVector3 } from 'angular-three';
113
import { NgtsOrthographicCamera } from 'angular-three-soba/cameras';
124
import { NgtsOrbitControls } from 'angular-three-soba/controls';
@@ -35,23 +27,22 @@ type CupGLTF = GLTF & {
3527
[scale]="2"
3628
>
3729
<ngt-value [rawValue]="1" attach="material.aoMapIntensity" />
38-
<ngt-group [position]="[0, 0.75, 0.5]">
39-
<ngts-pivot-controls
40-
[options]="{ activeAxes: [true, true, false], scale: 0.55 }"
41-
(dragged)="onDrag($event)"
42-
/>
43-
</ngt-group>
30+
<!-- <ngt-group [position]="[0, 0.75, 0.5]">-->
31+
<!-- &lt;!&ndash; TODO: not sure why Pivot Controls is not working within the gltf &ndash;&gt;-->
32+
<!-- <ngts-pivot-controls-->
33+
<!-- [options]="{ activeAxes: [true, true, false], scale: 0.55 }"-->
34+
<!-- (dragged)="onDrag($event)"-->
35+
<!-- />-->
36+
<!-- </ngt-group>-->
4437
<ngts-decal
45-
[options]="{
46-
map: logoTexture(),
47-
position: position(),
48-
rotation: rotation(),
49-
scale: scale(),
50-
depthTest: true,
51-
}"
38+
[options]="{ map: texture(), position: position(), rotation: rotation(), scale: scale(), depthTest: true }"
5239
/>
5340
</ngt-mesh>
5441
}
42+
43+
<ngt-group [position]="[0, 0.5, 1]">
44+
<ngts-pivot-controls [options]="{ activeAxes: [true, true, false], scale: 0.55 }" (dragged)="onDrag($event)" />
45+
</ngt-group>
5546
`,
5647
schemas: [CUSTOM_ELEMENTS_SCHEMA],
5748
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -63,25 +54,18 @@ export class Cup {
6354
protected scale = signal<NgtVector3>([0.6, 0.6, 0.6]);
6455

6556
protected gltf = injectGLTF(() => './coffee-transformed.glb') as Signal<CupGLTF | null>;
66-
protected logoTexture = injectTexture(() => './1200px-Starbucks_Logo_ab_2011.svg.png');
67-
68-
decal = viewChild(NgtsDecal);
57+
protected texture = injectTexture(() => './1200px-Starbucks_Logo_ab_2011.svg.png');
6958

70-
constructor() {
71-
effect(() => {
72-
console.log(this.decal()?.meshRef().nativeElement);
73-
});
74-
}
59+
private p = new Vector3();
60+
private s = new Vector3();
61+
private q = new Quaternion();
7562

7663
onDrag({ l }: OnDragParameters) {
77-
const position = new Vector3();
78-
const scale = new Vector3();
79-
const quaternion = new Quaternion();
80-
l.decompose(position, quaternion, scale);
81-
const rotation = new Euler().setFromQuaternion(quaternion);
82-
this.position.set([position.x, position.y + 0.75, position.z + 0.3]);
64+
l.decompose(this.p, this.q, this.s);
65+
const rotation = new Euler().setFromQuaternion(this.q);
66+
this.position.set([this.p.x, this.p.y + 0.75, this.p.z + 0.3]);
8367
this.rotation.set([rotation.x, rotation.y, rotation.z]);
84-
this.scale.set([0.6 * scale.x, 0.6 * scale.y, 0.6 * scale.z]);
68+
this.scale.set([0.6 * this.s.x, 0.6 * this.s.y, 0.6 * this.s.z]);
8569
}
8670
}
8771

0 commit comments

Comments
 (0)