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' ;
10
2
import { NgtArgs , NgtEuler , NgtVector3 } from 'angular-three' ;
11
3
import { NgtsOrthographicCamera } from 'angular-three-soba/cameras' ;
12
4
import { NgtsOrbitControls } from 'angular-three-soba/controls' ;
@@ -35,23 +27,22 @@ type CupGLTF = GLTF & {
35
27
[scale]="2"
36
28
>
37
29
<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
+ <!-- <!– TODO: not sure why Pivot Controls is not working within the gltf –>-->
32
+ <!-- <ngts-pivot-controls-->
33
+ <!-- [options]="{ activeAxes: [true, true, false], scale: 0.55 }"-->
34
+ <!-- (dragged)="onDrag($event)"-->
35
+ <!-- />-->
36
+ <!-- </ngt-group>-->
44
37
<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 }"
52
39
/>
53
40
</ngt-mesh>
54
41
}
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>
55
46
` ,
56
47
schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
57
48
changeDetection : ChangeDetectionStrategy . OnPush ,
@@ -63,25 +54,18 @@ export class Cup {
63
54
protected scale = signal < NgtVector3 > ( [ 0.6 , 0.6 , 0.6 ] ) ;
64
55
65
56
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' ) ;
69
58
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 ( ) ;
75
62
76
63
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 ] ) ;
83
67
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 ] ) ;
85
69
}
86
70
}
87
71
0 commit comments