Skip to content

Commit 70a8e48

Browse files
authored
Update vr controller UI (#200)
feat: implemented Hold Object tool feat: Implemented Drop User tool fix: Cleaned up VR UI tools. They appear to be working well. fix: Cleaned up minor issues in the ToolManager. feat: Toolmanager.pushTool can now accept a tool fix: fixed bugs in the VRController UI * VRControllerUI now works with generic DOM tree. * opening the UI now requires an explicit button click. fix: fixed issues with freehand line tool feat: implemented VR FrameAll * Big cleanup to the way tools greate geometries.
1 parent 2c11e04 commit 70a8e48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+114527
-786
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@rollup/plugin-commonjs": "^21.0.1",
6565
"@rollup/plugin-json": "^4.1.0",
6666
"@rollup/plugin-node-resolve": "^13.0.6",
67-
"@zeainc/zea-collab": "^6.0.1",
67+
"@zeainc/zea-collab": "^6.3.2",
6868
"@zeainc/zea-engine": "next",
6969
"canvas": "^2.6.1",
7070
"copyfiles": "^2.4.1",

src/Handles/AxialRotationHandle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ class AxialRotationHandle extends Handle {
6868
this.handle = new GeomItem('handle', handleGeom, this.handleMat)
6969

7070
this.radiusParam.on('valueChanged', () => {
71-
radius = this.radiusParam.getValue()
71+
radius = this.radiusParam.value
7272
handleGeom.outerRadiusParam.value = radius
7373
handleGeom.innerRadiusParam.value = radius * 0.02
7474
})
7575

7676
this.colorParam.on('valueChanged', () => {
77-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
77+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
7878
})
7979

8080
this.addChild(this.handle)
@@ -85,15 +85,15 @@ class AxialRotationHandle extends Handle {
8585
*/
8686
highlight(): void {
8787
super.highlight()
88-
this.handleMat.getParameter('BaseColor').value = this.highlightColorParam.getValue()
88+
this.handleMat.getParameter('BaseColor').value = this.highlightColorParam.value
8989
}
9090

9191
/**
9292
* Removes the highlight from the handle once the mouse moves away.
9393
*/
9494
unhighlight(): void {
9595
super.unhighlight()
96-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
96+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
9797
}
9898

9999
/**

src/Handles/BaseLinearMovementHandle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Vec3, ZeaPointerEvent, ZeaMouseEvent, ZeaTouchEvent, XRControllerEvent } from '@zeainc/zea-engine'
1+
import { Vec3, ZeaPointerEvent, ZeaMouseEvent, ZeaTouchEvent, XRControllerEvent, XRPoseEvent } from '@zeainc/zea-engine'
22

33
import { getPointerRay } from '../utility'
44
import Handle from './Handle'
@@ -74,7 +74,7 @@ class BaseLinearMovementHandle extends Handle {
7474
*
7575
* @param event - The event param.
7676
*/
77-
onVRControllerButtonDown(event: XRControllerEvent): void {
77+
onXRControllerButtonDown(event: XRControllerEvent): void {
7878
this.gizmoRay = this.getManipulationPlane()
7979

8080
this.activeController = event.controller
@@ -87,11 +87,11 @@ class BaseLinearMovementHandle extends Handle {
8787
}
8888

8989
/**
90-
* The onVRPoseChanged method.
90+
* The onXRPoseChanged method.
9191
*
9292
* @param event - The event param.
9393
*/
94-
onVRPoseChanged(event: XRControllerEvent): void {
94+
onXRPoseChanged(event: XRPoseEvent): void {
9595
const xfo = this.activeController.getTipXfo()
9696
const dist = xfo.tr.subtract(this.gizmoRay.start).dot(this.gizmoRay.dir)
9797
this.holdPos = this.gizmoRay.start.add(this.gizmoRay.dir.scale(dist))

src/Handles/Handle.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ZeaMouseEvent,
1111
ZeaTouchEvent,
1212
XRControllerEvent,
13+
XRPoseEvent,
1314
} from '@zeainc/zea-engine' // , PointerEvent
1415

1516
import { getPointerRay } from '../utility'
@@ -107,10 +108,10 @@ class Handle extends TreeItem {
107108
this.highlight()
108109
}
109110

110-
if (event.pointerType == 'mouse' || event.pointerType == 'touch') {
111+
if (event instanceof ZeaMouseEvent || event instanceof ZeaTouchEvent) {
111112
this.handlePointerDown(event)
112-
} else if (event.pointerType == 'xr') {
113-
this.onVRControllerButtonDown(<XRControllerEvent>event)
113+
} else if (event instanceof XRControllerEvent) {
114+
this.onXRControllerButtonDown(event)
114115
}
115116
}
116117

@@ -122,10 +123,10 @@ class Handle extends TreeItem {
122123
onPointerMove(event: ZeaPointerEvent): void {
123124
if (this.captured) {
124125
event.stopPropagation()
125-
if (event.pointerType == 'mouse' || event.pointerType == 'touch') {
126-
this.handlePointerMove(<ZeaMouseEvent>event)
127-
} else if (event.pointerType == 'xr') {
128-
this.onVRPoseChanged(<XRControllerEvent>event)
126+
if (event instanceof ZeaMouseEvent || event instanceof ZeaTouchEvent) {
127+
this.handlePointerMove(event)
128+
} else if (event instanceof XRPoseEvent) {
129+
this.onXRPoseChanged(event)
129130
}
130131
}
131132

@@ -146,10 +147,10 @@ class Handle extends TreeItem {
146147
if (event instanceof ZeaTouchEvent) {
147148
this.unhighlight()
148149
}
149-
if (event.pointerType == 'mouse' || event.pointerType == 'touch') {
150-
this.handlePointerUp(<ZeaMouseEvent>event)
151-
} else if (event.pointerType == 'xr') {
152-
this.onVRControllerButtonUp(<XRControllerEvent>event)
150+
if (event instanceof ZeaMouseEvent || event instanceof ZeaTouchEvent) {
151+
this.handlePointerUp(event)
152+
} else if (event instanceof XRControllerEvent) {
153+
this.onVRControllerButtonUp(event)
153154
}
154155
}
155156
}
@@ -206,8 +207,8 @@ class Handle extends TreeItem {
206207
*
207208
* @param event - The event param.
208209
*/
209-
handlePointerUp(event: ZeaMouseEvent): void {
210-
const ray = getPointerRay(event)
210+
handlePointerUp(event: ZeaPointerEvent): void {
211+
const ray = event.pointerRay
211212
if (ray) {
212213
const dist = ray.intersectRayPlane(this.gizmoRay)
213214
this.releasePos = ray.pointAtDist(dist)
@@ -224,7 +225,7 @@ class Handle extends TreeItem {
224225
*
225226
* @param event - The event param.
226227
*/
227-
onVRControllerButtonDown(event: XRControllerEvent): void {
228+
onXRControllerButtonDown(event: XRControllerEvent): void {
228229
this.activeController = event.controller
229230
const xfo = this.activeController.getTipXfo().clone()
230231

@@ -236,11 +237,11 @@ class Handle extends TreeItem {
236237
}
237238

238239
/**
239-
* The onVRPoseChanged method.
240+
* The onXRPoseChanged method.
240241
*
241242
* @param event - The event param.
242243
*/
243-
onVRPoseChanged(event: XRControllerEvent): void {
244+
onXRPoseChanged(event: XRPoseEvent): void {
244245
if (this.activeController) {
245246
const xfo = this.activeController.getTipXfo()
246247
const gizmoRay = this.getManipulationPlane()

src/Handles/LinearScaleHandle.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class LinearScaleHandle extends BaseLinearMovementHandle {
6666
transformVertices(tipGeom, tipXfo)
6767

6868
this.colorParam.on('valueChanged', () => {
69-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
69+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
7070
})
7171
this.addChild(handle)
7272
this.addChild(tip)
@@ -77,15 +77,15 @@ class LinearScaleHandle extends BaseLinearMovementHandle {
7777
*/
7878
highlight(): void {
7979
super.highlight()
80-
this.handleMat.getParameter('BaseColor').value = this.highlightColorParam.getValue()
80+
this.handleMat.getParameter('BaseColor').value = this.highlightColorParam.value
8181
}
8282

8383
/**
8484
* Removes the highlight from the handle once the mouse moves away.
8585
*/
8686
unhighlight(): void {
8787
super.unhighlight()
88-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
88+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
8989
}
9090

9191
/**
@@ -122,9 +122,9 @@ class LinearScaleHandle extends BaseLinearMovementHandle {
122122
*/
123123
onDragStart(event: ZeaPointerEvent): void {
124124
this.oriXfo = this.globalXfoParam.value
125-
this.tmplocalXfo = this.localXfoParam.getValue()
125+
this.tmplocalXfo = this.localXfoParam.value
126126
const param = this.getTargetParam()
127-
this.baseXfo = <Xfo>param.getValue()
127+
this.baseXfo = <Xfo>param.value
128128

129129
if (this.selectionGroup) {
130130
const items = this.selectionGroup.getItems()
@@ -188,7 +188,7 @@ class LinearScaleHandle extends BaseLinearMovementHandle {
188188
this.localXfoParam.value = this.tmplocalXfo
189189

190190
const tip = this.getChildByName('tip')
191-
const tipXfo = tip.localXfoParam.getValue()
191+
const tipXfo = tip.localXfoParam.value
192192
tipXfo.sc.set(1, 1, 1)
193193
tip.localXfoParam.value = tipXfo
194194
}

src/Handles/PlanarMovementHandle.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Handle from './Handle'
22
import ParameterValueChange from '../UndoRedo/Changes/ParameterValueChange'
33
import UndoRedoManager from '../UndoRedo/UndoRedoManager'
4-
import { Parameter, Vec3, Xfo, ZeaPointerEvent, XRControllerEvent, XfoParameter } from '@zeainc/zea-engine'
4+
import { Parameter, Vec3, Xfo, ZeaPointerEvent, XRControllerEvent, XfoParameter, XRPoseEvent } from '@zeainc/zea-engine'
55
import { Change } from '..'
66
import SelectionGroup from '../SelectionGroup'
77
import SelectionXfoChange from '../UndoRedo/Changes/SelectionXfoChange'
@@ -118,23 +118,23 @@ class PlanarMovementHandle extends Handle {
118118
* @param event - The event param.
119119
* @return {boolean} The return value.
120120
*/
121-
onVRControllerButtonDown(event: XRControllerEvent): void {
121+
onXRControllerButtonDown(event: XRControllerEvent): void {
122122
if (this.fullXfoManipulationInVR) {
123123
this.activeController = event.controller
124124
const xfo = this.activeController.getTipXfo()
125125
const handleXfo = this.globalXfoParam.value
126126
this.grabOffset = xfo.inverse().multiply(handleXfo)
127127
} else {
128-
super.onVRControllerButtonDown(event)
128+
super.onXRControllerButtonDown(event)
129129
}
130130
}
131131

132132
/**
133-
* The onVRPoseChanged method.
133+
* The onXRPoseChanged method.
134134
*
135135
* @param event - The event param.
136136
*/
137-
onVRPoseChanged(event: XRControllerEvent): void {
137+
onXRPoseChanged(event: XRPoseEvent): void {
138138
if (this.fullXfoManipulationInVR) {
139139
const xfo = this.activeController.getTipXfo()
140140
const newXfo = xfo.multiply(this.grabOffset)
@@ -147,7 +147,7 @@ class PlanarMovementHandle extends Handle {
147147
param.value = newXfo
148148
}
149149
} else {
150-
super.onVRPoseChanged(event)
150+
super.onXRPoseChanged(event)
151151
}
152152
}
153153

src/Handles/Shaders/HandleShader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ void main(void) {
231231
*/
232232
static getPackedMaterialData(material: Material): Float32Array {
233233
const matData = new Float32Array(8)
234-
const baseColor = material.getParameter('BaseColor').getValue()
234+
const baseColor = material.getParameter('BaseColor').value
235235
matData[0] = baseColor.r
236236
matData[1] = baseColor.g
237237
matData[2] = baseColor.b
238238
matData[3] = baseColor.a
239-
matData[4] = material.getParameter('MaintainScreenSize').getValue()
240-
matData[5] = material.getParameter('Overlay').getValue()
239+
matData[4] = material.getParameter('MaintainScreenSize').value
240+
matData[5] = material.getParameter('Overlay').value
241241
return matData
242242
}
243243

src/Handles/SliderHandle.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SliderHandle extends BaseLinearMovementHandle {
6363
this.colorParam.value = color
6464

6565
this.handleMat = new Material('handle', 'FlatSurfaceShader')
66-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
66+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
6767

6868
const topBarMat = new Material('topBar', 'FlatSurfaceShader')
6969
topBarMat.getParameter('BaseColor').value = new Color(0.5, 0.5, 0.5)
@@ -76,16 +76,16 @@ class SliderHandle extends BaseLinearMovementHandle {
7676
this.topBar = new GeomItem('topBar', barGeom, topBarMat)
7777

7878
this.barRadiusParam.on('valueChanged', () => {
79-
barGeom.radiusParam.value = this.barRadiusParam.getValue()
79+
barGeom.radiusParam.value = this.barRadiusParam.value
8080
})
8181
this.handleRadiusParam.on('valueChanged', () => {
82-
handleGeom.radiusParam.value = this.handleRadiusParam.getValue()
82+
handleGeom.radiusParam.value = this.handleRadiusParam.value
8383
})
8484
this.lengthParam.on('valueChanged', () => {
8585
this.__updateSlider(<number>this.value)
8686
})
8787
this.colorParam.on('valueChanged', () => {
88-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
88+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
8989
})
9090

9191
this.addChild(this.handle)
@@ -100,15 +100,15 @@ class SliderHandle extends BaseLinearMovementHandle {
100100
*/
101101
highlight(): void {
102102
super.highlight()
103-
this.handleMat.getParameter('BaseColor').value = this.highlightColorParam.getValue()
103+
this.handleMat.getParameter('BaseColor').value = this.highlightColorParam.value
104104
}
105105

106106
/**
107107
* Removes the highlight from the handle once the mouse moves away.
108108
*/
109109
unhighlight(): void {
110110
super.unhighlight()
111-
this.handleMat.getParameter('BaseColor').value = this.colorParam.getValue()
111+
this.handleMat.getParameter('BaseColor').value = this.colorParam.value
112112
}
113113

114114
/**
@@ -119,7 +119,7 @@ class SliderHandle extends BaseLinearMovementHandle {
119119
setTargetParam(param: Parameter<unknown>): void {
120120
this.param = param
121121
const __updateSlider = () => {
122-
this.__updateSlider(<number>param.getValue())
122+
this.__updateSlider(<number>param.value)
123123
}
124124
__updateSlider()
125125
param.on('valueChanged', __updateSlider)
@@ -136,7 +136,7 @@ class SliderHandle extends BaseLinearMovementHandle {
136136
const param = <NumberParameter>this.param
137137
const range = param && param.getRange() ? param.getRange() : [0, 1]
138138
const v = MathFunctions.remap(value, range[0], range[1], 0, 1)
139-
const length = this.lengthParam.getValue()
139+
const length = this.lengthParam.value
140140
this.baseBarXfo.sc.z = v * length
141141
this.handleXfo.tr.z = v * length
142142
this.topBarXfo.tr.z = v * length
@@ -172,7 +172,7 @@ class SliderHandle extends BaseLinearMovementHandle {
172172
* @param event - The event param.
173173
*/
174174
onDrag(event: ZeaPointerEvent): void {
175-
const length = this.lengthParam.getValue()
175+
const length = this.lengthParam.value
176176
const param = <NumberParameter>this.param
177177
const range = param && param.getRange() ? param.getRange() : [0, 1]
178178
const value = MathFunctions.clamp(

src/Handles/SphericalRotationHandle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SphericalRotationHandle extends Handle {
5454
const maskGeomItem = new GeomItem('mask', maskGeom, this.maskMat)
5555

5656
this.colorParam.on('valueChanged', () => {
57-
this.maskMat.getParameter('BaseColor').value = this.colorParam.getValue()
57+
this.maskMat.getParameter('BaseColor').value = this.colorParam.value
5858
})
5959

6060
this.addChild(maskGeomItem)

src/Handles/ViewCube.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class ViewCube extends TreeItem {
297297
const target = camera.getTargetPosition()
298298
const dist = camera.getFocalDistance()
299299

300-
const startXfo = camera.globalXfoParam.getValue()
300+
const startXfo = camera.globalXfoParam.value
301301
const startUp = startXfo.ori.getYaxis()
302302
startUp.subtractInPlace(normal.scale(startUp.dot(normal)))
303303

0 commit comments

Comments
 (0)