|
@@ -17,18 +17,16 @@ export class Controls extends PluginComponent<{ }, { }> {
|
|
|
|
|
|
private _snap: any = void 0;
|
|
|
private getSnapshot = () => {
|
|
|
- this._snap = this.context.state.getSnapshot();
|
|
|
+ this._snap = this.plugin.state.getSnapshot();
|
|
|
console.log(btoa(JSON.stringify(this._snap)));
|
|
|
}
|
|
|
private setSnapshot = () => {
|
|
|
if (!this._snap) return;
|
|
|
- this.context.state.setSnapshot(this._snap);
|
|
|
+ this.plugin.state.setSnapshot(this._snap);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
return <div>
|
|
|
- <button onClick={() => this.context._test_centerView()}>Center View</button><br />
|
|
|
- <hr />
|
|
|
<button onClick={this.getSnapshot}>Get Snapshot</button>
|
|
|
<button onClick={this.setSnapshot}>Set Snapshot</button>
|
|
|
</div>;
|
|
@@ -40,16 +38,16 @@ export class _test_TrajectoryControls extends PluginComponent {
|
|
|
render() {
|
|
|
return <div>
|
|
|
<b>Trajectory: </b>
|
|
|
- <button onClick={() => PluginCommands.State.ApplyAction.dispatch(this.context, {
|
|
|
- state: this.context.state.data,
|
|
|
+ <button onClick={() => PluginCommands.State.ApplyAction.dispatch(this.plugin, {
|
|
|
+ state: this.plugin.state.data,
|
|
|
action: UpdateTrajectory.create({ action: 'advance', by: -1 })
|
|
|
})}><<</button>
|
|
|
- <button onClick={() => PluginCommands.State.ApplyAction.dispatch(this.context, {
|
|
|
- state: this.context.state.data,
|
|
|
+ <button onClick={() => PluginCommands.State.ApplyAction.dispatch(this.plugin, {
|
|
|
+ state: this.plugin.state.data,
|
|
|
action: UpdateTrajectory.create({ action: 'reset' })
|
|
|
})}>Reset</button>
|
|
|
- <button onClick={() => PluginCommands.State.ApplyAction.dispatch(this.context, {
|
|
|
- state: this.context.state.data,
|
|
|
+ <button onClick={() => PluginCommands.State.ApplyAction.dispatch(this.plugin, {
|
|
|
+ state: this.plugin.state.data,
|
|
|
action: UpdateTrajectory.create({ action: 'advance', by: +1 })
|
|
|
})}>>></button><br />
|
|
|
</div>
|
|
@@ -67,7 +65,7 @@ export class _test_ApplyAction extends PluginComponent<{ nodeRef: Transform.Ref,
|
|
|
if (!p || !p.default) return {};
|
|
|
const obj = this.getObj();
|
|
|
if (!obj.obj) return {};
|
|
|
- return p.default(obj.obj, this.context);
|
|
|
+ return p.default(obj.obj, this.plugin);
|
|
|
}
|
|
|
|
|
|
private getParamDef() {
|
|
@@ -75,12 +73,12 @@ export class _test_ApplyAction extends PluginComponent<{ nodeRef: Transform.Ref,
|
|
|
if (!p || !p.controls) return {};
|
|
|
const obj = this.getObj();
|
|
|
if (!obj.obj) return {};
|
|
|
- return p.controls(obj.obj, this.context);
|
|
|
+ return p.controls(obj.obj, this.plugin);
|
|
|
}
|
|
|
|
|
|
private create() {
|
|
|
console.log('Apply Action', this.state.params);
|
|
|
- PluginCommands.State.ApplyAction.dispatch(this.context, {
|
|
|
+ PluginCommands.State.ApplyAction.dispatch(this.plugin, {
|
|
|
state: this.props.state,
|
|
|
action: this.props.action.create(this.state.params),
|
|
|
ref: this.props.nodeRef
|
|
@@ -130,12 +128,12 @@ export class _test_UpdateTransform extends PluginComponent<{ state: State, nodeR
|
|
|
const src = this.getCell(cell.sourceRef);
|
|
|
if (!src || !src.obj) return void 0;
|
|
|
|
|
|
- return def.params.controls(src.obj, this.context);
|
|
|
+ return def.params.controls(src.obj, this.plugin);
|
|
|
}
|
|
|
|
|
|
private update() {
|
|
|
console.log(this.props.nodeRef, this.state.params);
|
|
|
- this.context.updateTransform(this.props.state, this.props.nodeRef, this.state.params);
|
|
|
+ this.plugin.updateTransform(this.props.state, this.props.nodeRef, this.state.params);
|
|
|
}
|
|
|
|
|
|
// componentDidMount() {
|