Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gizmo updates #6992

Merged
merged 42 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
cee0d59
refactored functions into arrow-funcs axis-shape
kpal81xd Aug 5, 2024
9759d44
Moved each shape to separate file
kpal81xd Aug 5, 2024
2878257
cleaned up applying shadow to shapes
kpal81xd Aug 5, 2024
7d5cde9
Merge branch 'main' into gizmo-shape
kpal81xd Aug 7, 2024
1052d6b
Applied eslint fixes
kpal81xd Aug 7, 2024
a3ba6b4
Merge branch 'main' into gizmo-shape
kpal81xd Aug 22, 2024
8d2fd3e
Removed extra app parameter from gizmo
kpal81xd Sep 25, 2024
2578529
removed ts imports
kpal81xd Sep 25, 2024
50dff2a
Merge branch 'gizmo-shape' into gizmos
kpal81xd Sep 25, 2024
2f659c5
cleaned up shape creation
kpal81xd Sep 25, 2024
cd1186c
added shadows option to render
kpal81xd Sep 25, 2024
cf83f5f
moved shadows to shape setting
kpal81xd Sep 25, 2024
e4b2615
added shadow toggling
kpal81xd Sep 25, 2024
0aa0d0b
Fixed updating shadows option on gizmos
kpal81xd Sep 25, 2024
8e2ca4d
default create gizmo layer
kpal81xd Sep 25, 2024
259cf72
layer is checked to exist already before creating new layer
kpal81xd Sep 25, 2024
e2fa7f3
removed layer creation from editor example
kpal81xd Sep 25, 2024
30d862a
renamed shadows to shading
kpal81xd Sep 25, 2024
73144ae
renamed shadows to shading option
kpal81xd Sep 25, 2024
fc6600b
added option for single node in gizmo attach
kpal81xd Sep 25, 2024
657aacc
Merge branch 'main' into gizmos
kpal81xd Sep 26, 2024
7e07158
set shading to be off by default
kpal81xd Sep 26, 2024
0b33431
put update position and rotation inside update for two way binding
kpal81xd Sep 26, 2024
9fc765e
reverted local position and rotation
kpal81xd Sep 26, 2024
a528d3a
Added gizmo layer referencing for removal
kpal81xd Sep 26, 2024
9df55c9
Merge branch 'main' into gizmos
kpal81xd Sep 26, 2024
cac094e
only fire events on change
kpal81xd Sep 26, 2024
2a2c086
removed flip axis and fixed types
kpal81xd Sep 26, 2024
4000c46
minor fixes
kpal81xd Sep 26, 2024
ca5d784
refactored shape shading
kpal81xd Sep 26, 2024
c617f2f
minor fixes
kpal81xd Sep 26, 2024
a738062
fixed tridata types issue
kpal81xd Sep 26, 2024
b36d6f2
Fixed destroy issue
kpal81xd Sep 26, 2024
5319479
created separate layer per app
kpal81xd Sep 27, 2024
aad6d7b
Update src/extras/gizmo/tri-data.js
kpal81xd Sep 27, 2024
c6d38a2
fixed layer cleanup
kpal81xd Sep 27, 2024
95f2451
Added description of the layer parameter to the gizmo
kpal81xd Sep 27, 2024
b2a7ef6
Use deviceCache instead of map for gizmo layer management
kpal81xd Sep 27, 2024
746f87c
removed extra space
kpal81xd Sep 27, 2024
3ad43a1
Modified layer to be supplied with static helper function
kpal81xd Sep 27, 2024
dc50956
adjusted default params
kpal81xd Sep 27, 2024
1aed679
updated default to be undefined for layerIndex
kpal81xd Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion examples/src/examples/gizmos/transform-rotate.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as pc from 'playcanvas';
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput } = ReactPCUI;
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput, BooleanInput } = ReactPCUI;

const [proj, setProj] = React.useState(pc.PROJECTION_PERSPECTIVE);

Expand Down Expand Up @@ -84,6 +84,15 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
max: 1,
precision: 2
})
),
jsx(
LabelGroup,
{ text: 'Shading' },
jsx(BooleanInput, {
type: 'toggle',
binding: new BindingTwoWay(),
link: { observer, path: 'gizmo.shading' }
})
)
),
jsx(
Expand Down
17 changes: 4 additions & 13 deletions examples/src/examples/gizmos/transform-rotate.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,18 @@ light.addComponent('light');
app.root.addChild(light);
light.setEulerAngles(0, 0, -60);

// create layers
const gizmoLayer = new pc.Layer({
name: 'Gizmo',
clearDepthBuffer: true,
opaqueSortMode: pc.SORTMODE_NONE,
transparentSortMode: pc.SORTMODE_NONE
});
const layers = app.scene.layers;
layers.push(gizmoLayer);
camera.camera.layers = camera.camera.layers.concat(gizmoLayer.id);

// create gizmo
const gizmo = new pc.RotateGizmo(app, camera.camera, gizmoLayer);
gizmo.attach([box]);
const layer = pc.Gizmo.createLayer(app);
const gizmo = new pc.RotateGizmo(camera.camera, layer);
gizmo.attach(box);
data.set('gizmo', {
size: gizmo.size,
snapIncrement: gizmo.snapIncrement,
xAxisColor: Object.values(gizmo.xAxisColor),
yAxisColor: Object.values(gizmo.yAxisColor),
zAxisColor: Object.values(gizmo.zAxisColor),
colorAlpha: gizmo.colorAlpha,
shading: gizmo.shading,
coordSpace: gizmo.coordSpace,
ringTolerance: gizmo.ringTolerance,
xyzTubeRadius: gizmo.xyzTubeRadius,
Expand Down
11 changes: 10 additions & 1 deletion examples/src/examples/gizmos/transform-scale.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as pc from 'playcanvas';
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput } = ReactPCUI;
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput, BooleanInput } = ReactPCUI;

const [proj, setProj] = React.useState(pc.PROJECTION_PERSPECTIVE);

Expand Down Expand Up @@ -72,6 +72,15 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
max: 1,
precision: 2
})
),
jsx(
LabelGroup,
{ text: 'Shading' },
jsx(BooleanInput, {
type: 'toggle',
binding: new BindingTwoWay(),
link: { observer, path: 'gizmo.shading' }
})
)
),
jsx(
Expand Down
17 changes: 4 additions & 13 deletions examples/src/examples/gizmos/transform-scale.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,18 @@ light.addComponent('light');
app.root.addChild(light);
light.setEulerAngles(0, 0, -60);

// create layers
const gizmoLayer = new pc.Layer({
name: 'Gizmo',
clearDepthBuffer: true,
opaqueSortMode: pc.SORTMODE_NONE,
transparentSortMode: pc.SORTMODE_NONE
});
const layers = app.scene.layers;
layers.push(gizmoLayer);
camera.camera.layers = camera.camera.layers.concat(gizmoLayer.id);

// create gizmo
const gizmo = new pc.ScaleGizmo(app, camera.camera, gizmoLayer);
gizmo.attach([box]);
const layer = pc.Gizmo.createLayer(app);
const gizmo = new pc.ScaleGizmo(camera.camera, layer);
gizmo.attach(box);
data.set('gizmo', {
size: gizmo.size,
snapIncrement: gizmo.snapIncrement,
xAxisColor: Object.values(gizmo.xAxisColor),
yAxisColor: Object.values(gizmo.yAxisColor),
zAxisColor: Object.values(gizmo.zAxisColor),
colorAlpha: gizmo.colorAlpha,
shading: gizmo.shading,
coordSpace: gizmo.coordSpace,
axisLineTolerance: gizmo.axisLineTolerance,
axisCenterTolerance: gizmo.axisCenterTolerance,
Expand Down
11 changes: 10 additions & 1 deletion examples/src/examples/gizmos/transform-translate.controls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as pc from 'playcanvas';
* @returns {JSX.Element} The returned JSX Element.
*/
export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput } = ReactPCUI;
const { BindingTwoWay, LabelGroup, Panel, ColorPicker, SliderInput, SelectInput, BooleanInput } = ReactPCUI;

const [proj, setProj] = React.useState(pc.PROJECTION_PERSPECTIVE);

Expand Down Expand Up @@ -84,6 +84,15 @@ export function controls({ observer, ReactPCUI, React, jsx, fragment }) {
max: 1,
precision: 2
})
),
jsx(
LabelGroup,
{ text: 'Shading' },
jsx(BooleanInput, {
type: 'toggle',
binding: new BindingTwoWay(),
link: { observer, path: 'gizmo.shading' }
})
)
),
jsx(
Expand Down
17 changes: 4 additions & 13 deletions examples/src/examples/gizmos/transform-translate.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,18 @@ light.addComponent('light');
app.root.addChild(light);
light.setEulerAngles(0, 0, -60);

// create layers
const gizmoLayer = new pc.Layer({
name: 'Gizmo',
clearDepthBuffer: true,
opaqueSortMode: pc.SORTMODE_NONE,
transparentSortMode: pc.SORTMODE_NONE
});
const layers = app.scene.layers;
layers.push(gizmoLayer);
camera.camera.layers = camera.camera.layers.concat(gizmoLayer.id);

// create gizmo
const gizmo = new pc.TranslateGizmo(app, camera.camera, gizmoLayer);
gizmo.attach([box]);
const layer = pc.Gizmo.createLayer(app);
const gizmo = new pc.TranslateGizmo(camera.camera, layer);
gizmo.attach(box);
data.set('gizmo', {
size: gizmo.size,
snapIncrement: gizmo.snapIncrement,
xAxisColor: Object.values(gizmo.xAxisColor),
yAxisColor: Object.values(gizmo.yAxisColor),
zAxisColor: Object.values(gizmo.zAxisColor),
colorAlpha: gizmo.colorAlpha,
shading: gizmo.shading,
coordSpace: gizmo.coordSpace,
axisLineTolerance: gizmo.axisLineTolerance,
axisCenterTolerance: gizmo.axisCenterTolerance,
Expand Down
14 changes: 2 additions & 12 deletions examples/src/examples/misc/editor.example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,9 @@ light.addComponent('light', {
app.root.addChild(light);
light.setEulerAngles(0, 0, -60);

// create layers
const gizmoLayer = new pc.Layer({
name: 'Gizmo',
clearDepthBuffer: true,
opaqueSortMode: pc.SORTMODE_NONE,
transparentSortMode: pc.SORTMODE_NONE
});
const layers = app.scene.layers;
layers.push(gizmoLayer);
camera.camera.layers = camera.camera.layers.concat(gizmoLayer.id);

// create gizmo
let skipObserverFire = false;
const gizmoHandler = new GizmoHandler(app, camera.camera, gizmoLayer);
const gizmoHandler = new GizmoHandler(camera.camera);
const setGizmoControls = () => {
skipObserverFire = true;
data.set('gizmo', {
Expand Down Expand Up @@ -261,6 +250,7 @@ data.on('*:set', (/** @type {string} */ path, /** @type {any} */ value) => {
});

// selector
const layers = app.scene.layers;
const selector = new Selector(app, camera.camera, [layers.getLayerByName('World')]);
selector.on('select', (/** @type {pc.GraphNode} */ node, /** @type {boolean} */ clear) => {
if (gizmoHandler.hasPointer) {
Expand Down
11 changes: 5 additions & 6 deletions examples/src/examples/misc/editor.gizmo-handler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ class GizmoHandler {
_hasPointer = false;

/**
* @param {pc.AppBase} app - The application.
* @param {pc.CameraComponent} camera - The camera component.
* @param {pc.Layer} layer - The gizmo layer
*/
constructor(app, camera, layer) {
constructor(camera) {
const layer = pc.Gizmo.createLayer(camera.system.app);
this._gizmos = {
translate: new pc.TranslateGizmo(app, camera, layer),
rotate: new pc.RotateGizmo(app, camera, layer),
scale: new pc.ScaleGizmo(app, camera, layer)
translate: new pc.TranslateGizmo(camera, layer),
rotate: new pc.RotateGizmo(camera, layer),
scale: new pc.ScaleGizmo(camera, layer)
};

for (const type in this._gizmos) {
Expand Down
Loading