|
@@ -1,28 +1,28 @@
|
|
-import * as React from "react";
|
|
|
|
-import { Animation } from "babylonjs/Animations/animation";
|
|
|
|
-import { Vector2, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
|
|
|
|
-import { Color3, Color4 } from "babylonjs/Maths/math.color";
|
|
|
|
-import { Size } from "babylonjs/Maths/math.size";
|
|
|
|
-import { EasingFunction } from "babylonjs/Animations/easing";
|
|
|
|
-import { IAnimationKey } from "babylonjs/Animations/animationKey";
|
|
|
|
-import { IKeyframeSvgPoint } from "./keyframeSvgPoint";
|
|
|
|
-import { SvgDraggableArea } from "./svgDraggableArea";
|
|
|
|
-import { Timeline } from "./timeline";
|
|
|
|
-import { Notification } from "./notification";
|
|
|
|
-import { GraphActionsBar } from "./graphActionsBar";
|
|
|
|
-import { Scene } from "babylonjs/scene";
|
|
|
|
-import { IAnimatable } from "babylonjs/Animations/animatable.interface";
|
|
|
|
-import { Animatable } from "babylonjs/Animations/animatable";
|
|
|
|
-import { TargetedAnimation } from "babylonjs/Animations/animationGroup";
|
|
|
|
-import { EditorControls } from "./editorControls";
|
|
|
|
-import { SelectedCoordinate } from "./animationListTree";
|
|
|
|
-import { LockObject } from "../lockObject";
|
|
|
|
-import { GlobalState } from "../../../../globalState";
|
|
|
|
-import { Nullable } from "babylonjs/types";
|
|
|
|
-import { Observer } from "babylonjs/Misc/observable";
|
|
|
|
-import { ScaleLabel } from "./scale-label";
|
|
|
|
-
|
|
|
|
-require("./curveEditor.scss");
|
|
|
|
|
|
+import * as React from 'react';
|
|
|
|
+import { Animation } from 'babylonjs/Animations/animation';
|
|
|
|
+import { Vector2, Vector3, Quaternion } from 'babylonjs/Maths/math.vector';
|
|
|
|
+import { Color3, Color4 } from 'babylonjs/Maths/math.color';
|
|
|
|
+import { Size } from 'babylonjs/Maths/math.size';
|
|
|
|
+import { EasingFunction } from 'babylonjs/Animations/easing';
|
|
|
|
+import { IAnimationKey } from 'babylonjs/Animations/animationKey';
|
|
|
|
+import { IKeyframeSvgPoint } from './keyframeSvgPoint';
|
|
|
|
+import { SvgDraggableArea } from './svgDraggableArea';
|
|
|
|
+import { Timeline } from './timeline';
|
|
|
|
+import { Notification } from './notification';
|
|
|
|
+import { GraphActionsBar } from './graphActionsBar';
|
|
|
|
+import { Scene } from 'babylonjs/scene';
|
|
|
|
+import { IAnimatable } from 'babylonjs/Animations/animatable.interface';
|
|
|
|
+import { Animatable } from 'babylonjs/Animations/animatable';
|
|
|
|
+import { TargetedAnimation } from 'babylonjs/Animations/animationGroup';
|
|
|
|
+import { EditorControls } from './editorControls';
|
|
|
|
+import { SelectedCoordinate } from './animationListTree';
|
|
|
|
+import { LockObject } from '../lockObject';
|
|
|
|
+import { GlobalState } from '../../../../globalState';
|
|
|
|
+import { Nullable } from 'babylonjs/types';
|
|
|
|
+import { Observer } from 'babylonjs/Misc/observable';
|
|
|
|
+import { ScaleLabel } from './scale-label';
|
|
|
|
+
|
|
|
|
+require('./curveEditor.scss');
|
|
|
|
|
|
interface IAnimationCurveEditorComponentProps {
|
|
interface IAnimationCurveEditorComponentProps {
|
|
close: (event: any) => void;
|
|
close: (event: any) => void;
|
|
@@ -91,7 +91,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
valueScale: CurveScale;
|
|
valueScale: CurveScale;
|
|
}
|
|
}
|
|
> {
|
|
> {
|
|
- private _snippetUrl = "https://snippet.babylonjs.com";
|
|
|
|
|
|
+ private _snippetUrl = 'https://snippet.babylonjs.com';
|
|
// Height scale *Review this functionaliy
|
|
// Height scale *Review this functionaliy
|
|
private _heightScale: number = 100;
|
|
private _heightScale: number = 100;
|
|
// Canvas Length *Review this functionality
|
|
// Canvas Length *Review this functionality
|
|
@@ -158,7 +158,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
valueAxisLength: new Array(10).fill(0).map((s, i) => {
|
|
valueAxisLength: new Array(10).fill(0).map((s, i) => {
|
|
return { value: i * 10, label: valueInd[i] };
|
|
return { value: i * 10, label: valueInd[i] };
|
|
}),
|
|
}),
|
|
- notification: "",
|
|
|
|
|
|
+ notification: '',
|
|
currentPoint: undefined,
|
|
currentPoint: undefined,
|
|
scale: 1,
|
|
scale: 1,
|
|
playheadPos: 0,
|
|
playheadPos: 0,
|
|
@@ -185,7 +185,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
* To add notification we set the state and clear to make the notification bar hide.
|
|
* To add notification we set the state and clear to make the notification bar hide.
|
|
*/
|
|
*/
|
|
clearNotification() {
|
|
clearNotification() {
|
|
- this.setState({ notification: "" });
|
|
|
|
|
|
+ this.setState({ notification: '' });
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -318,12 +318,12 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
}
|
|
}
|
|
|
|
|
|
encodeCurveId(animationName: string, coordinate: number) {
|
|
encodeCurveId(animationName: string, coordinate: number) {
|
|
- return animationName + "_" + coordinate;
|
|
|
|
|
|
+ return animationName + '_' + coordinate;
|
|
}
|
|
}
|
|
|
|
|
|
decodeCurveId(id: string) {
|
|
decodeCurveId(id: string) {
|
|
- const order = parseInt(id.split("_")[3]);
|
|
|
|
- const coordinate = parseInt(id.split("_")[2]);
|
|
|
|
|
|
+ const order = parseInt(id.split('_')[3]);
|
|
|
|
+ const coordinate = parseInt(id.split('_')[2]);
|
|
return { order, coordinate };
|
|
return { order, coordinate };
|
|
}
|
|
}
|
|
|
|
|
|
@@ -375,11 +375,11 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
let updatedKeyframes = this.state.svgKeyframes?.map((kf) => {
|
|
let updatedKeyframes = this.state.svgKeyframes?.map((kf) => {
|
|
if (kf.id === id) {
|
|
if (kf.id === id) {
|
|
this.setState({ isFlatTangentMode: false });
|
|
this.setState({ isFlatTangentMode: false });
|
|
- if (type === "left") {
|
|
|
|
|
|
+ if (type === 'left') {
|
|
kf.isLeftActive = !kf.isLeftActive;
|
|
kf.isLeftActive = !kf.isLeftActive;
|
|
kf.isRightActive = false;
|
|
kf.isRightActive = false;
|
|
}
|
|
}
|
|
- if (type === "right") {
|
|
|
|
|
|
+ if (type === 'right') {
|
|
kf.isRightActive = !kf.isRightActive;
|
|
kf.isRightActive = !kf.isRightActive;
|
|
kf.isLeftActive = false;
|
|
kf.isLeftActive = false;
|
|
}
|
|
}
|
|
@@ -600,8 +600,8 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
|
|
|
let frame;
|
|
let frame;
|
|
- if (event.target.value === "") {
|
|
|
|
- frame = "";
|
|
|
|
|
|
+ if (event.target.value === '') {
|
|
|
|
+ frame = '';
|
|
} else {
|
|
} else {
|
|
frame = parseInt(event.target.value);
|
|
frame = parseInt(event.target.value);
|
|
}
|
|
}
|
|
@@ -620,10 +620,10 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
let value;
|
|
let value;
|
|
|
|
|
|
if (event.target.value !== undefined) {
|
|
if (event.target.value !== undefined) {
|
|
- if (event.target.value !== "") {
|
|
|
|
|
|
+ if (event.target.value !== '') {
|
|
value = parseFloat(event.target.value);
|
|
value = parseFloat(event.target.value);
|
|
} else {
|
|
} else {
|
|
- value = "";
|
|
|
|
|
|
+ value = '';
|
|
}
|
|
}
|
|
|
|
|
|
this.setState({
|
|
this.setState({
|
|
@@ -636,7 +636,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
}
|
|
}
|
|
|
|
|
|
setKeyframeValue() {
|
|
setKeyframeValue() {
|
|
- if (this.state.actionableKeyframe.frame !== "" && this.state.actionableKeyframe.frame !== undefined && this.state.actionableKeyframe.value !== "" && this.state.actionableKeyframe.value !== undefined) {
|
|
|
|
|
|
+ if (this.state.actionableKeyframe.frame !== '' && this.state.actionableKeyframe.frame !== undefined && this.state.actionableKeyframe.value !== '' && this.state.actionableKeyframe.value !== undefined) {
|
|
if (this.state.selected !== null) {
|
|
if (this.state.selected !== null) {
|
|
let currentSelected = this.state.svgKeyframes?.find((kf) => kf.selected);
|
|
let currentSelected = this.state.svgKeyframes?.find((kf) => kf.selected);
|
|
if (currentSelected) {
|
|
if (currentSelected) {
|
|
@@ -753,8 +753,8 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
|
|
|
|
const indexesToRemove = points.map((p) => {
|
|
const indexesToRemove = points.map((p) => {
|
|
return {
|
|
return {
|
|
- index: parseInt(p.id.split("_")[3]),
|
|
|
|
- coordinate: parseInt(p.id.split("_")[2]),
|
|
|
|
|
|
+ index: parseInt(p.id.split('_')[3]),
|
|
|
|
+ coordinate: parseInt(p.id.split('_')[2]),
|
|
};
|
|
};
|
|
});
|
|
});
|
|
|
|
|
|
@@ -945,7 +945,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
const startKey = keyframes[0];
|
|
const startKey = keyframes[0];
|
|
let middle = this._heightScale / 2;
|
|
let middle = this._heightScale / 2;
|
|
let collection: ICurveData[] = [];
|
|
let collection: ICurveData[] = [];
|
|
- const colors = ["red", "green", "blue", "white", "#7a4ece"];
|
|
|
|
|
|
+ const colors = ['red', 'green', 'blue', 'white', '#7a4ece'];
|
|
const startValue = this.getValueAsArray(valueType, startKey.value);
|
|
const startValue = this.getValueAsArray(valueType, startKey.value);
|
|
|
|
|
|
for (var d = 0; d < startValue.length; d++) {
|
|
for (var d = 0; d < startValue.length; d++) {
|
|
@@ -1004,7 +1004,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
let framesPerSecond = animation.framePerSecond;
|
|
let framesPerSecond = animation.framePerSecond;
|
|
let highestFrame = animation.getHighestFrame();
|
|
let highestFrame = animation.getHighestFrame();
|
|
//let serialized = animation.serialize();
|
|
//let serialized = animation.serialize();
|
|
- let usesTangents = animation.getKeys().find((kf) => kf.hasOwnProperty("inTangent") || kf.hasOwnProperty("outTangent")) !== undefined ? true : false;
|
|
|
|
|
|
+ let usesTangents = animation.getKeys().find((kf) => kf.hasOwnProperty('inTangent') || kf.hasOwnProperty('outTangent')) !== undefined ? true : false;
|
|
let valueType = animation.dataType;
|
|
let valueType = animation.dataType;
|
|
// easing properties
|
|
// easing properties
|
|
let easingType, easingMode;
|
|
let easingType, easingMode;
|
|
@@ -1271,7 +1271,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
updatedPath = [];
|
|
updatedPath = [];
|
|
|
|
|
|
filteredSvgKeys = this._svgKeyframes?.filter((curve) => {
|
|
filteredSvgKeys = this._svgKeyframes?.filter((curve) => {
|
|
- let id = parseInt(curve.id.split("_")[2]);
|
|
|
|
|
|
+ let id = parseInt(curve.id.split('_')[2]);
|
|
if (id === coordinate) {
|
|
if (id === coordinate) {
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
@@ -1280,7 +1280,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
});
|
|
});
|
|
|
|
|
|
curves?.map((curve) => {
|
|
curves?.map((curve) => {
|
|
- let id = parseInt(curve.id.split("_")[2]);
|
|
|
|
|
|
+ let id = parseInt(curve.id.split('_')[2]);
|
|
if (id === coordinate) {
|
|
if (id === coordinate) {
|
|
updatedPath.push(curve);
|
|
updatedPath.push(curve);
|
|
}
|
|
}
|
|
@@ -1471,7 +1471,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
render() {
|
|
render() {
|
|
return (
|
|
return (
|
|
<div id="animation-curve-editor">
|
|
<div id="animation-curve-editor">
|
|
- <Notification message={this.state.notification} open={this.state.notification !== "" ? true : false} close={() => this.clearNotification()} />
|
|
|
|
|
|
+ <Notification message={this.state.notification} open={this.state.notification !== '' ? true : false} close={() => this.clearNotification()} />
|
|
<GraphActionsBar
|
|
<GraphActionsBar
|
|
setKeyframeValue={() => this.setKeyframeValue()}
|
|
setKeyframeValue={() => this.setKeyframeValue()}
|
|
enabled={this.state.selected === null || this.state.selected === undefined ? false : true}
|
|
enabled={this.state.selected === null || this.state.selected === undefined ? false : true}
|
|
@@ -1543,8 +1543,8 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
d={curve.pathData}
|
|
d={curve.pathData}
|
|
style={{
|
|
style={{
|
|
stroke: curve.color,
|
|
stroke: curve.color,
|
|
- fill: "none",
|
|
|
|
- strokeWidth: "0.5",
|
|
|
|
|
|
+ fill: 'none',
|
|
|
|
+ strokeWidth: '0.5',
|
|
}}
|
|
}}
|
|
></path>
|
|
></path>
|
|
))}
|
|
))}
|
|
@@ -1560,8 +1560,8 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
dy="-1"
|
|
dy="-1"
|
|
style={{
|
|
style={{
|
|
fontSize: `${0.18 * this.state.scale}em`,
|
|
fontSize: `${0.18 * this.state.scale}em`,
|
|
- fontWeight: "bold",
|
|
|
|
- textAlign: "center",
|
|
|
|
|
|
+ fontWeight: 'bold',
|
|
|
|
+ textAlign: 'center',
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
{line.label}
|
|
{line.label}
|
|
@@ -1573,10 +1573,10 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
return <line key={i} x1={-((this.state.frameAxisLength.length * 10) / 2)} y1={line.value} x2={this.state.frameAxisLength.length * 10} y2={line.value}></line>;
|
|
return <line key={i} x1={-((this.state.frameAxisLength.length * 10) / 2)} y1={line.value} x2={this.state.frameAxisLength.length * 10} y2={line.value}></line>;
|
|
})}
|
|
})}
|
|
|
|
|
|
- <rect onClick={(e) => this.moveFrameTo(e)} x={-((this.state.frameAxisLength.length * 10) / 2)} y={90 + this.state.panningY + "%"} width={this.state.frameAxisLength.length * 10} height="10%" fill="#222" style={{ cursor: "pointer" }}></rect>
|
|
|
|
|
|
+ <rect onClick={(e) => this.moveFrameTo(e)} x={-((this.state.frameAxisLength.length * 10) / 2)} y={90 + this.state.panningY + '%'} width={this.state.frameAxisLength.length * 10} height="10%" fill="#222" style={{ cursor: 'pointer' }}></rect>
|
|
|
|
|
|
{this.state.frameAxisLength.map((f, i) => (
|
|
{this.state.frameAxisLength.map((f, i) => (
|
|
- <svg key={i} x="0" y={96 + this.state.panningY + "%"} className="frame-contain">
|
|
|
|
|
|
+ <svg key={i} x="0" y={96 + this.state.panningY + '%'} className="frame-contain">
|
|
<text x={f.value} y="0" dx="2px" style={{ fontSize: `${0.17 * this.state.scale}em` }}>
|
|
<text x={f.value} y="0" dx="2px" style={{ fontSize: `${0.17 * this.state.scale}em` }}>
|
|
{f.label}
|
|
{f.label}
|
|
</text>
|
|
</text>
|
|
@@ -1592,7 +1592,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
x2={f.value}
|
|
x2={f.value}
|
|
y2="-100%"
|
|
y2="-100%"
|
|
style={{
|
|
style={{
|
|
- stroke: "white",
|
|
|
|
|
|
+ stroke: 'white',
|
|
strokeWidth: 0.4,
|
|
strokeWidth: 0.4,
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
@@ -1604,7 +1604,7 @@ export class AnimationCurveEditorComponent extends React.Component<
|
|
textAnchor="middle"
|
|
textAnchor="middle"
|
|
style={{
|
|
style={{
|
|
fontSize: `${0.17 * this.state.scale}em`,
|
|
fontSize: `${0.17 * this.state.scale}em`,
|
|
- pointerEvents: "none",
|
|
|
|
|
|
+ pointerEvents: 'none',
|
|
fontWeight: 600,
|
|
fontWeight: 600,
|
|
}}
|
|
}}
|
|
>
|
|
>
|