Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

fix-spline-component #9037

Merged
merged 2 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 15 additions & 4 deletions packages/editor/src/components/properties/SplineNodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SplineComponent } from '@etherealengine/engine/src/scene/components/Spl
import ClearIcon from '@mui/icons-material/Clear'
import TimelineIcon from '@mui/icons-material/Timeline'

import { NO_PROXY } from '@etherealengine/hyperflux'
import { Quaternion, Vector3 } from 'three'
import { PropertiesPanelButton } from '../inputs/Button'
import EulerInput from '../inputs/EulerInput'
Expand All @@ -57,7 +58,7 @@ export const SplineNodeEditor: EditorComponentType = (props) => {
<PropertiesPanelButton
onClick={() => {
const elem = { position: new Vector3(), quaternion: new Quaternion() }
const newElements = [...elements.value, elem]
const newElements = [...elements.get(NO_PROXY), elem]
commitProperty(SplineComponent, 'elements')(newElements)
}}
>
Expand All @@ -70,7 +71,7 @@ export const SplineNodeEditor: EditorComponentType = (props) => {
<div style={{ display: 'flex-row' }}>
<ClearIcon
onClick={() => {
const newElements = [...elements.value].filter((_, i) => i !== index)
const newElements = [...elements.get(NO_PROXY)].filter((_, i) => i !== index)
commitProperty(SplineComponent, 'elements')(newElements)
}}
style={{ color: 'white' }}
Expand All @@ -82,15 +83,25 @@ export const SplineNodeEditor: EditorComponentType = (props) => {
smallStep={0.01}
mediumStep={0.1}
largeStep={1}
onChange={commitProperty(SplineComponent, `elements.${index}.position` as any)}
onChange={(position) => {
commitProperty(
SplineComponent,
`elements.${index}.position` as any
)(new Vector3(position.x, position.y, position.z))
}}
/>
</InputGroup>
<InputGroup name="Rotation" label={`${t('editor:properties.transform.lbl-rotation')} ${index + 1}`}>
<EulerInput
//style={{ maxWidth: 'calc(100% - 2px)', paddingRight: `3px`, width: '100%' }}
quaternion={elem.quaternion.value}
unit="°"
onChange={commitProperty(SplineComponent, `elements.${index}.quaternion` as any)}
onChange={(euler) => {
commitProperty(
SplineComponent,
`elements.${index}.quaternion` as any
)(new Quaternion().setFromEuler(euler))
}}
/>
</InputGroup>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import NumericInput from '../inputs/NumericInput'
import SelectInput from '../inputs/SelectInput'
import { Vector3Scrubber } from '../inputs/Vector3Input'
import NodeEditor from './NodeEditor'
import { EditorComponentType, commitProperty } from './Util'
import { EditorComponentType, commitProperty, updateProperty } from './Util'

/**
* SplineTrackNodeEditor adds rotation editing to splines.
Expand All @@ -65,25 +65,11 @@ export const SplineTrackNodeEditor: EditorComponentType = (props) => {
})

// @todo allow these to be passed in or remove this capability
const onChange = () => {}
const onRelease = () => {}

const setAlpha = (value) => {
component.alpha.set(value)
}

const setRunning = (value) => {
component.loop.set(component.loop.value ? false : true)
}

const setVelocity = (value) => {
component.velocity.set(value)
}

const setRoll = () => {
component.enableRotation.set(component.enableRotation.value ? false : true)
}

return (
<NodeEditor description={t('editor:properties.splinetrack.description')} {...props}>
<InputGroup name="Spline" label={t('editor:properties.splinetrack.lbl-spline')}>
Expand All @@ -97,9 +83,16 @@ export const SplineTrackNodeEditor: EditorComponentType = (props) => {
<InputGroup name="Velocity" label={t('editor:properties.splinetrack.lbl-velocity')}>
<NumericInput
value={velocity.value}
onChange={setVelocity}
onRelease={onRelease}
prefix={<Vector3Scrubber tag="div" value={velocity.value} onChange={setVelocity} onPointerUp={onRelease} />}
onChange={updateProperty(SplineTrackComponent, 'velocity')}
onRelease={commitProperty(SplineTrackComponent, 'velocity')}
prefix={
<Vector3Scrubber
tag="div"
value={velocity.value}
onChange={updateProperty(SplineTrackComponent, 'velocity')}
onPointerUp={commitProperty(SplineTrackComponent, 'velocity')}
/>
}
/>
</InputGroup>
<InputGroup name="Enable Rotation" label={t('editor:properties.splinetrack.lbl-enableRotation')}>
Expand Down