зеркало из https://github.com/mozilla/Spoke.git
Merge pull request #1183 from mozilla/update-optional-ui
Update optional UI
This commit is contained in:
Коммит
14be6f21bc
|
@ -64,7 +64,10 @@ export default function EditorNodeMixin(Object3DClass) {
|
|||
|
||||
if (editorSettingsComponent) {
|
||||
node.enabled = editorSettingsComponent.props.enabled;
|
||||
node.modifiedProperties = editorSettingsComponent.props.modifiedProperties;
|
||||
node._modifiedProperties =
|
||||
editorSettingsComponent.props.modifiedProperties === undefined
|
||||
? {}
|
||||
: JSON.parse(JSON.stringify(editorSettingsComponent.props.modifiedProperties));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +125,8 @@ export default function EditorNodeMixin(Object3DClass) {
|
|||
this.issues = source.issues.slice();
|
||||
this._visible = source._visible;
|
||||
this.enabled = source.enabled;
|
||||
this._modifiedProperties = source.modifiedProperties;
|
||||
this._modifiedProperties =
|
||||
source._modifiedProperties === undefined ? {} : JSON.parse(JSON.stringify(source._modifiedProperties));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -191,7 +195,8 @@ export default function EditorNodeMixin(Object3DClass) {
|
|||
name: "editor-settings",
|
||||
props: {
|
||||
enabled: this.enabled,
|
||||
modifiedProperties: this.modifiedProperties
|
||||
modifiedProperties:
|
||||
this._modifiedProperties === undefined ? {} : JSON.parse(JSON.stringify(this._modifiedProperties))
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -463,17 +468,26 @@ export default function EditorNodeMixin(Object3DClass) {
|
|||
}
|
||||
|
||||
optionalPropertyExportValue(componentName, propName) {
|
||||
if (this.modifiedProperties[componentName]) {
|
||||
return this.modifiedProperties[componentName][propName] ? this[propName] : undefined;
|
||||
if (this._modifiedProperties[componentName]) {
|
||||
return this._modifiedProperties[componentName].includes(propName) ? this[propName] : undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
set modifiedProperties(object) {
|
||||
if (object) {
|
||||
const keys = Object.keys(object);
|
||||
keys.forEach(key => {
|
||||
this._modifiedProperties[key] = { ...this._modifiedProperties[key], ...object[key] };
|
||||
const compKeys = Object.keys(object);
|
||||
compKeys.forEach(compKey => {
|
||||
const modifiedProps = new Set(this._modifiedProperties[compKey]);
|
||||
const propKeys = Object.keys(object[compKey]);
|
||||
propKeys.forEach(propKey => {
|
||||
if (object[compKey][propKey] === true) {
|
||||
modifiedProps.add(propKey);
|
||||
} else {
|
||||
modifiedProps.delete(propKey);
|
||||
}
|
||||
});
|
||||
this._modifiedProperties[compKey] = Array.from(modifiedProps);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ function migrateV6ToV7(json) {
|
|||
const audioParamsComponent = entity.components.find(c => c.name === "audio-params");
|
||||
if (audioParamsComponent) {
|
||||
// Prior to V6 we didn't have dirty params so we need to enable all properties
|
||||
// to make sure that the old settings are applied config is enabled.
|
||||
// to make sure that the old settings are applied.
|
||||
let editorSettingsComponent = entity.components.find(c => c.name === "editor-settings");
|
||||
if (!editorSettingsComponent) {
|
||||
editorSettingsComponent = {
|
||||
|
@ -298,7 +298,7 @@ function migrateV6ToV7(json) {
|
|||
if (audioSettingsComponent) {
|
||||
const overriden = audioSettingsComponent.props && audioSettingsComponent.props.overrideAudioSettings;
|
||||
// Prior to V6 we didn't have dirty params so we need to enable all properties
|
||||
// to make sure that the old settings are applied config is enabled.
|
||||
// to make sure that the old settings are applied.
|
||||
if (overriden) {
|
||||
let editorSettingsComponent = entity.components.find(c => c.name === "editor-settings");
|
||||
if (!editorSettingsComponent) {
|
||||
|
@ -333,6 +333,61 @@ function migrateV6ToV7(json) {
|
|||
return json;
|
||||
}
|
||||
|
||||
function migrateV7ToV8(json) {
|
||||
json.version = 8;
|
||||
|
||||
for (const entityId in json.entities) {
|
||||
if (!Object.prototype.hasOwnProperty.call(json.entities, entityId)) continue;
|
||||
|
||||
const entity = json.entities[entityId];
|
||||
|
||||
if (!entity.components) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const updateModifiedProps = oldProps => {
|
||||
const compKeys = Object.keys(oldProps["modifiedProperties"]);
|
||||
compKeys.forEach(compKey => {
|
||||
const newModifiedProps = [];
|
||||
const propKeys = Object.keys(oldProps["modifiedProperties"][compKey]);
|
||||
propKeys.forEach(propKey => {
|
||||
if (oldProps["modifiedProperties"][compKey][propKey] === true) {
|
||||
newModifiedProps.push(propKey);
|
||||
}
|
||||
});
|
||||
oldProps["modifiedProperties"][compKey] = newModifiedProps;
|
||||
});
|
||||
};
|
||||
|
||||
const audioParamsComponent = entity.components.find(c => c.name === "audio-params");
|
||||
if (audioParamsComponent) {
|
||||
// Migrate old modified params object to a set
|
||||
const editorSettingsComponent = entity.components.find(c => c.name === "editor-settings");
|
||||
const modifiedProps = editorSettingsComponent.props["modifiedProperties"];
|
||||
if (modifiedProps) {
|
||||
updateModifiedProps(editorSettingsComponent.props);
|
||||
}
|
||||
}
|
||||
|
||||
const audioSettingsComponent = entity.components.find(c => c.name === "audio-settings");
|
||||
if (audioSettingsComponent) {
|
||||
const overriden = audioSettingsComponent.props && audioSettingsComponent.props.overrideAudioSettings;
|
||||
// Migrate old modified params object to a se
|
||||
if (overriden) {
|
||||
const editorSettingsComponent = entity.components.find(c => c.name === "editor-settings");
|
||||
if (editorSettingsComponent) {
|
||||
const modifiedProps = editorSettingsComponent.props["modifiedProperties"];
|
||||
if (modifiedProps) {
|
||||
updateModifiedProps(editorSettingsComponent.props);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
export const FogType = {
|
||||
Disabled: "disabled",
|
||||
Linear: "linear",
|
||||
|
@ -373,6 +428,10 @@ export default class SceneNode extends EditorNodeMixin(Scene) {
|
|||
json = migrateV6ToV7(json);
|
||||
}
|
||||
|
||||
if (json.version === 7) {
|
||||
json = migrateV7ToV8(json);
|
||||
}
|
||||
|
||||
const { root, metadata, entities } = json;
|
||||
|
||||
let scene = null;
|
||||
|
@ -610,7 +669,7 @@ export default class SceneNode extends EditorNodeMixin(Scene) {
|
|||
|
||||
serialize() {
|
||||
const sceneJson = {
|
||||
version: 7,
|
||||
version: 8,
|
||||
root: this.uuid,
|
||||
metadata: JSON.parse(JSON.stringify(this.metadata)),
|
||||
entities: {
|
||||
|
|
|
@ -97,7 +97,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get audioType() {
|
||||
return this._audioType;
|
||||
return this._audioType || Defaults[this.sourceType].audioType;
|
||||
}
|
||||
|
||||
set audioType(type) {
|
||||
|
@ -105,7 +105,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get gain() {
|
||||
return this._gain;
|
||||
return this._gain || Defaults[this.sourceType].gain;
|
||||
}
|
||||
|
||||
set gain(value) {
|
||||
|
@ -113,7 +113,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get distanceModel() {
|
||||
return this._distanceModel;
|
||||
return this._distanceModel || Defaults[this.sourceType].distanceModel;
|
||||
}
|
||||
|
||||
set distanceModel(value) {
|
||||
|
@ -121,7 +121,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get rolloffFactor() {
|
||||
return this._rolloffFactor;
|
||||
return this._rolloffFactor || Defaults[this.sourceType].rolloffFactor;
|
||||
}
|
||||
|
||||
set rolloffFactor(value) {
|
||||
|
@ -129,7 +129,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get refDistance() {
|
||||
return this._refDistance;
|
||||
return this._refDistance || Defaults[this.sourceType].refDistance;
|
||||
}
|
||||
|
||||
set refDistance(value) {
|
||||
|
@ -137,7 +137,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get maxDistance() {
|
||||
return this._maxDistance;
|
||||
return this._maxDistance || Defaults[this.sourceType].maxDistance;
|
||||
}
|
||||
|
||||
set maxDistance(value) {
|
||||
|
@ -145,7 +145,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get coneInnerAngle() {
|
||||
return this._coneInnerAngle;
|
||||
return this._coneInnerAngle || Defaults[this.sourceType].coneInnerAngle;
|
||||
}
|
||||
|
||||
set coneInnerAngle(value) {
|
||||
|
@ -153,7 +153,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get coneOuterAngle() {
|
||||
return this._coneOuterAngle;
|
||||
return this._coneOuterAngle || Defaults[this.sourceType].coneOuterAngle;
|
||||
}
|
||||
|
||||
set coneOuterAngle(value) {
|
||||
|
@ -161,7 +161,7 @@ export default class AudioParams extends Object3D {
|
|||
}
|
||||
|
||||
get coneOuterGain() {
|
||||
return this._coneOuterGain;
|
||||
return this._coneOuterGain || Defaults[this.sourceType].coneOuterGain;
|
||||
}
|
||||
|
||||
set coneOuterGain(value) {
|
||||
|
|
|
@ -3,8 +3,8 @@ import PropTypes from "prop-types";
|
|||
import styled from "styled-components";
|
||||
import { QuestionCircle } from "styled-icons/fa-regular/QuestionCircle";
|
||||
import { InfoTooltip } from "../layout/Tooltip";
|
||||
import BooleanInput from "./BooleanInput";
|
||||
import ResetButton from "./ResetButton";
|
||||
import { PropertyLabel } from "./PropertyLabel";
|
||||
|
||||
export const InputGroupContainer = styled.div`
|
||||
display: flex;
|
||||
|
@ -12,7 +12,6 @@ export const InputGroupContainer = styled.div`
|
|||
padding: 4px 8px;
|
||||
flex: 1;
|
||||
min-height: 24px;
|
||||
align-items: center;
|
||||
|
||||
${props =>
|
||||
props.disabled &&
|
||||
|
@ -23,6 +22,7 @@ export const InputGroupContainer = styled.div`
|
|||
|
||||
& > label {
|
||||
display: block;
|
||||
width: 25%;
|
||||
color: ${props => props.theme.text2};
|
||||
padding-bottom: 2px;
|
||||
padding-top: 4px;
|
||||
|
@ -30,15 +30,9 @@ export const InputGroupContainer = styled.div`
|
|||
`;
|
||||
|
||||
export const InputGroupContent = styled.div`
|
||||
${props =>
|
||||
props.disabled &&
|
||||
`
|
||||
pointer-events: none;
|
||||
opacity: 0.3;
|
||||
`}
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 2;
|
||||
flex: 1;
|
||||
padding-left: 8px;
|
||||
align-items: center;
|
||||
`;
|
||||
|
@ -52,38 +46,6 @@ export const InputGroupInfoIcon = styled(QuestionCircle)`
|
|||
align-self: center;
|
||||
`;
|
||||
|
||||
export const InputGroupHeader = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
|
||||
${props =>
|
||||
props.disabled &&
|
||||
`
|
||||
pointer-events: none;
|
||||
opacity: 0.3;
|
||||
`}
|
||||
|
||||
& > :first-child {
|
||||
padding-right: 8px;
|
||||
}
|
||||
`;
|
||||
|
||||
export const OptionalGroup = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
|
||||
${props =>
|
||||
props.disabled &&
|
||||
`
|
||||
pointer-events: none;
|
||||
opacity: 0.3;
|
||||
`}
|
||||
`;
|
||||
|
||||
export function InputGroupInfo({ info }) {
|
||||
return (
|
||||
<InfoTooltip info={info}>
|
||||
|
@ -96,14 +58,11 @@ InputGroupInfo.propTypes = {
|
|||
info: PropTypes.string
|
||||
};
|
||||
|
||||
export default function InputGroup({ name, children, disabled, info, optional, enabled, onEnable, reset, onReset }) {
|
||||
export default function InputGroup({ name, children, disabled, info, reset, onReset }) {
|
||||
return (
|
||||
<InputGroupContainer disabled={disabled}>
|
||||
<InputGroupHeader>
|
||||
{optional && <BooleanInput value={enabled} onChange={onEnable} />}
|
||||
<OptionalGroup disabled={optional && !enabled}>{name && <label>{name}:</label>}</OptionalGroup>
|
||||
</InputGroupHeader>
|
||||
<InputGroupContent disabled={optional && !enabled}>
|
||||
<PropertyLabel modified={!reset}>{name}:</PropertyLabel>
|
||||
<InputGroupContent>
|
||||
{children}
|
||||
{info && <InputGroupInfo info={info} />}
|
||||
{onReset && <ResetButton disabled={!reset} onClick={onReset} />}
|
||||
|
@ -118,9 +77,6 @@ InputGroup.propTypes = {
|
|||
disabled: PropTypes.bool,
|
||||
className: PropTypes.string,
|
||||
info: PropTypes.string,
|
||||
optional: PropTypes.bool,
|
||||
enabled: PropTypes.bool,
|
||||
onEnable: PropTypes.func,
|
||||
onReset: PropTypes.func,
|
||||
reset: PropTypes.bool
|
||||
};
|
||||
|
|
|
@ -1,36 +1,22 @@
|
|||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { InputGroupHeader, InputGroupContainer, InputGroupContent, InputGroupInfo, OptionalGroup } from "./InputGroup";
|
||||
import { InputGroupContainer, InputGroupContent, InputGroupInfo } from "./InputGroup";
|
||||
import Scrubber from "./Scrubber";
|
||||
import NumericInput from "./NumericInput";
|
||||
import BooleanInput from "./BooleanInput";
|
||||
import ResetButton from "./ResetButton";
|
||||
import { PropertyLabel } from "./PropertyLabel";
|
||||
|
||||
export default function NumericInputGroup({
|
||||
name,
|
||||
className,
|
||||
info,
|
||||
optional,
|
||||
children,
|
||||
enabled,
|
||||
onEnable,
|
||||
reset,
|
||||
onReset,
|
||||
...rest
|
||||
}) {
|
||||
export default function NumericInputGroup({ name, className, info, children, reset, onReset, ...rest }) {
|
||||
const { displayPrecision, ...scrubberProps } = rest;
|
||||
return (
|
||||
<InputGroupContainer>
|
||||
<InputGroupHeader>
|
||||
{optional && <BooleanInput value={enabled} onChange={onEnable} />}
|
||||
<OptionalGroup disabled={optional && !enabled}>
|
||||
<Scrubber {...scrubberProps}>{name}:</Scrubber>
|
||||
</OptionalGroup>
|
||||
</InputGroupHeader>
|
||||
<InputGroupContent disabled={optional && !enabled}>
|
||||
<Scrubber {...scrubberProps}>
|
||||
<PropertyLabel modified={!reset}>{name}:</PropertyLabel>
|
||||
</Scrubber>
|
||||
<InputGroupContent>
|
||||
<NumericInput {...rest} />
|
||||
{children}
|
||||
{info && <InputGroupInfo info={info} />}
|
||||
{info && <InputGroupInfo info={info} modified={reset} />}
|
||||
{onReset && <ResetButton disabled={!reset} onClick={onReset} />}
|
||||
</InputGroupContent>
|
||||
</InputGroupContainer>
|
||||
|
@ -42,9 +28,6 @@ NumericInputGroup.propTypes = {
|
|||
className: PropTypes.string,
|
||||
children: PropTypes.any,
|
||||
info: PropTypes.string,
|
||||
optional: PropTypes.bool,
|
||||
enabled: PropTypes.bool,
|
||||
onEnable: PropTypes.func,
|
||||
onReset: PropTypes.func,
|
||||
reset: PropTypes.bool
|
||||
};
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import styled from "styled-components";
|
||||
|
||||
export const PropertyLabel = styled.label`
|
||||
${props =>
|
||||
(props.modified &&
|
||||
`font-weight: normal;
|
||||
color: ${props.theme.text2};`) ||
|
||||
`font-weight: bold;
|
||||
color: ${props.theme.text}
|
||||
`}
|
||||
`;
|
|
@ -68,10 +68,10 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
</InputGroup>
|
||||
{node.overrideAudioSettings && (
|
||||
<>
|
||||
<InputGroup name="Audio Type" optional {...paramProps.audioType}>
|
||||
<InputGroup name="Audio Type" {...paramProps.audioType}>
|
||||
<SelectInput options={AudioTypeOptions} value={node.audioType} onChange={paramProps.audioType.onChange} />
|
||||
</InputGroup>
|
||||
<InputGroup name="Volume" optional {...paramProps.gain}>
|
||||
<InputGroup name="Volume" {...paramProps.gain}>
|
||||
<CompoundNumericInput value={node.gain} onChange={paramProps.gain.onChange} />
|
||||
</InputGroup>
|
||||
{!multiEdit && node.audioType === AudioType.PannerNode && (
|
||||
|
@ -79,7 +79,6 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
<InputGroup
|
||||
name="Distance Model"
|
||||
info="The algorithim used to calculate audio rolloff."
|
||||
optional
|
||||
{...paramProps.distanceModel}
|
||||
>
|
||||
<SelectInput
|
||||
|
@ -93,7 +92,6 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
<InputGroup
|
||||
name="Rolloff Factor"
|
||||
info="A double value describing how quickly the volume is reduced as the source moves away from the listener. 0 to 1"
|
||||
optional
|
||||
{...paramProps.rolloffFactor}
|
||||
>
|
||||
<CompoundNumericInput
|
||||
|
@ -115,7 +113,6 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
mediumStep={1}
|
||||
largeStep={10}
|
||||
value={node.rolloffFactor}
|
||||
optional
|
||||
onChange={paramProps.rolloffFactor.onChange}
|
||||
{...paramProps.rolloffFactor}
|
||||
/>
|
||||
|
@ -129,7 +126,6 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
largeStep={10}
|
||||
value={node.refDistance}
|
||||
unit="m"
|
||||
optional
|
||||
onChange={paramProps.refDistance.onChange}
|
||||
{...paramProps.refDistance}
|
||||
/>
|
||||
|
@ -142,7 +138,6 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
largeStep={10}
|
||||
value={node.maxDistance}
|
||||
unit="m"
|
||||
optional
|
||||
onChange={paramProps.maxDistance.onChange}
|
||||
{...paramProps.maxDistance}
|
||||
/>
|
||||
|
@ -157,7 +152,6 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
value={node.coneInnerAngle}
|
||||
unit="°"
|
||||
disabled={multiEdit}
|
||||
optional
|
||||
onChange={paramProps.coneInnerAngle.onChange}
|
||||
{...paramProps.coneInnerAngle}
|
||||
/>
|
||||
|
@ -172,14 +166,12 @@ export default function AudioParamsProperties({ node, editor, multiEdit, sourceT
|
|||
value={node.coneOuterAngle}
|
||||
unit="°"
|
||||
disabled={multiEdit}
|
||||
optional
|
||||
onChange={paramProps.coneOuterAngle.onChange}
|
||||
{...paramProps.coneOuterAngle}
|
||||
/>
|
||||
<InputGroup
|
||||
name="Cone Outer Gain"
|
||||
info="A double value describing the amount of volume reduction outside the cone defined by the coneOuterAngle attribute. Its default value is 0, meaning that no sound can be heard."
|
||||
optional
|
||||
{...paramProps.coneOuterGain}
|
||||
>
|
||||
<CompoundNumericInput
|
||||
|
|
|
@ -176,7 +176,6 @@ export default function SceneNodeEditor(props) {
|
|||
<InputGroup
|
||||
name="Avatar Distance Model"
|
||||
info="The algorithim used to calculate audio rolloff."
|
||||
optional
|
||||
{...avatarParamProps.distanceModel}
|
||||
>
|
||||
<SelectInput
|
||||
|
@ -190,7 +189,6 @@ export default function SceneNodeEditor(props) {
|
|||
<InputGroup
|
||||
name="Avatar Rolloff Factor"
|
||||
info="A double value describing how quickly the volume is reduced as the source moves away from the listener. 0 to 1"
|
||||
optional
|
||||
{...avatarParamProps.rolloffFactor}
|
||||
>
|
||||
<CompoundNumericInput
|
||||
|
@ -212,7 +210,6 @@ export default function SceneNodeEditor(props) {
|
|||
mediumStep={1}
|
||||
largeStep={10}
|
||||
value={node.avatarRolloffFactor}
|
||||
optional
|
||||
onChange={avatarParamProps.rolloffFactor.onChange}
|
||||
{...avatarParamProps.rolloffFactor}
|
||||
/>
|
||||
|
@ -226,7 +223,6 @@ export default function SceneNodeEditor(props) {
|
|||
largeStep={10}
|
||||
value={node.avatarRefDistance}
|
||||
unit="m"
|
||||
optional
|
||||
onChange={avatarParamProps.refDistance.onChange}
|
||||
{...avatarParamProps.refDistance}
|
||||
/>
|
||||
|
@ -239,17 +235,15 @@ export default function SceneNodeEditor(props) {
|
|||
largeStep={10}
|
||||
value={node.avatarMaxDistance}
|
||||
unit="m"
|
||||
optional
|
||||
onChange={avatarParamProps.maxDistance.onChange}
|
||||
{...avatarParamProps.maxDistance}
|
||||
/>
|
||||
<InputGroup name="Media Volume" optional {...mediaParamProps.gain}>
|
||||
<InputGroup name="Media Volume" {...mediaParamProps.gain}>
|
||||
<CompoundNumericInput value={node.mediaVolume} onChange={mediaParamProps.gain.onChange} />
|
||||
</InputGroup>
|
||||
<InputGroup
|
||||
name="Media Distance Model"
|
||||
info="The algorithim used to calculate audio rolloff."
|
||||
optional
|
||||
{...mediaParamProps.distanceModel}
|
||||
>
|
||||
<SelectInput
|
||||
|
@ -263,7 +257,6 @@ export default function SceneNodeEditor(props) {
|
|||
<InputGroup
|
||||
name="Media Rolloff Factor"
|
||||
info="A double value describing how quickly the volume is reduced as the source moves away from the listener. 0 to 1"
|
||||
optional
|
||||
{...mediaParamProps.rolloffFactor}
|
||||
>
|
||||
<CompoundNumericInput
|
||||
|
@ -285,7 +278,6 @@ export default function SceneNodeEditor(props) {
|
|||
mediumStep={1}
|
||||
largeStep={10}
|
||||
value={node.mediaRolloffFactor}
|
||||
optional
|
||||
onChange={mediaParamProps.rolloffFactor.onChange}
|
||||
{...mediaParamProps.rolloffFactor}
|
||||
/>
|
||||
|
@ -299,7 +291,6 @@ export default function SceneNodeEditor(props) {
|
|||
largeStep={10}
|
||||
value={node.mediaRefDistance}
|
||||
unit="m"
|
||||
optional
|
||||
onChange={mediaParamProps.refDistance.onChange}
|
||||
{...mediaParamProps.refDistance}
|
||||
/>
|
||||
|
@ -312,7 +303,6 @@ export default function SceneNodeEditor(props) {
|
|||
largeStep={10}
|
||||
value={node.mediaMaxDistance}
|
||||
unit="m"
|
||||
optional
|
||||
onChange={mediaParamProps.maxDistance.onChange}
|
||||
{...mediaParamProps.maxDistance}
|
||||
/>
|
||||
|
@ -326,7 +316,6 @@ export default function SceneNodeEditor(props) {
|
|||
largeStep={10}
|
||||
value={node.mediaConeInnerAngle}
|
||||
unit="°"
|
||||
optional
|
||||
onChange={mediaParamProps.coneInnerAngle.onChange}
|
||||
{...mediaParamProps.coneInnerAngle}
|
||||
/>
|
||||
|
@ -340,14 +329,12 @@ export default function SceneNodeEditor(props) {
|
|||
largeStep={10}
|
||||
value={node.mediaConeOuterAngle}
|
||||
unit="°"
|
||||
optional
|
||||
onChange={mediaParamProps.coneOuterAngle.onChange}
|
||||
{...mediaParamProps.coneOuterAngle}
|
||||
/>
|
||||
<InputGroup
|
||||
name="Media Cone Outer Gain"
|
||||
info="A double value describing the amount of volume reduction outside the cone defined by the coneOuterGain attribute. Its default value is 0, meaning that no sound can be heard."
|
||||
optional
|
||||
{...mediaParamProps.coneOuterGain}
|
||||
>
|
||||
<CompoundNumericInput
|
||||
|
|
|
@ -2,18 +2,27 @@ import { useCallback } from "react";
|
|||
|
||||
export default function useOptionalParam(node, editor, componentName, propName, defaultValue) {
|
||||
return {
|
||||
onChange: useCallback(value => editor.setPropertySelected(propName, value), [editor, propName]),
|
||||
onEnable: useCallback(
|
||||
value =>
|
||||
onChange: useCallback(
|
||||
value => {
|
||||
editor.setPropertySelected(propName, value);
|
||||
editor.setPropertySelected("modifiedProperties", {
|
||||
[componentName]: {
|
||||
[propName]: value
|
||||
[propName]: true
|
||||
}
|
||||
}),
|
||||
[editor, componentName, propName]
|
||||
});
|
||||
},
|
||||
[componentName, editor, propName]
|
||||
),
|
||||
enabled: node.modifiedProperties[componentName] ? node.modifiedProperties[componentName][propName] : false,
|
||||
onReset: useCallback(() => editor.setPropertySelected(propName, defaultValue), [editor, propName, defaultValue]),
|
||||
reset: node[propName] !== defaultValue
|
||||
onReset: useCallback(() => {
|
||||
editor.setPropertySelected(propName, defaultValue);
|
||||
editor.setPropertySelected("modifiedProperties", {
|
||||
[componentName]: {
|
||||
[propName]: false
|
||||
}
|
||||
});
|
||||
}, [editor, propName, defaultValue, componentName]),
|
||||
reset:
|
||||
node[propName] !== defaultValue ||
|
||||
(node.modifiedProperties[componentName] ? node.modifiedProperties[componentName].includes(propName) : false)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -230,17 +230,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1012,17 +1012,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1241,7 +1241,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
},
|
||||
metadata: {},
|
||||
root: 'FC94D12B-39AB-493B-848F-5290FFD4ECF9',
|
||||
version: 7,
|
||||
version: 8,
|
||||
}
|
||||
|
||||
## Editor should load V4TestScene
|
||||
|
@ -2078,17 +2078,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -2292,17 +2292,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -2619,7 +2619,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
},
|
||||
},
|
||||
root: '2266BED7-6CC4-48A6-95DD-9BCD3CF9EAFC',
|
||||
version: 7,
|
||||
version: 8,
|
||||
}
|
||||
|
||||
## Editor should load V5TestScene
|
||||
|
@ -3554,17 +3554,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -3768,17 +3768,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -4024,17 +4024,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -4246,7 +4246,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
},
|
||||
},
|
||||
root: '2266BED7-6CC4-48A6-95DD-9BCD3CF9EAFC',
|
||||
version: 7,
|
||||
version: 8,
|
||||
}
|
||||
|
||||
## Editor should load V6TestScene
|
||||
|
@ -5181,17 +5181,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -5395,17 +5395,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -5651,17 +5651,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
props: {
|
||||
enabled: true,
|
||||
modifiedProperties: {
|
||||
'audio-params': {
|
||||
audioType: true,
|
||||
coneInnerAngle: true,
|
||||
coneOuterAngle: true,
|
||||
coneOuterGain: true,
|
||||
distanceModel: true,
|
||||
gain: true,
|
||||
maxDistance: true,
|
||||
refDistance: true,
|
||||
rolloffFactor: true,
|
||||
},
|
||||
'audio-params': [
|
||||
'audioType',
|
||||
'gain',
|
||||
'distanceModel',
|
||||
'rolloffFactor',
|
||||
'refDistance',
|
||||
'maxDistance',
|
||||
'coneInnerAngle',
|
||||
'coneOuterAngle',
|
||||
'coneOuterGain',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -5873,7 +5873,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
},
|
||||
},
|
||||
root: '2266BED7-6CC4-48A6-95DD-9BCD3CF9EAFC',
|
||||
version: 7,
|
||||
version: 8,
|
||||
}
|
||||
|
||||
## Editor should load new scene
|
||||
|
@ -6207,5 +6207,5 @@ Generated by [AVA](https://avajs.dev).
|
|||
name: 'Crater',
|
||||
},
|
||||
root: '2266BED7-6CC4-48A6-95DD-9BCD3CF9EAFC',
|
||||
version: 7,
|
||||
version: 8,
|
||||
}
|
||||
|
|
Двоичные данные
test/integration/snapshots/Editor.test.js.snap
Двоичные данные
test/integration/snapshots/Editor.test.js.snap
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче