fix: fixed pasting between simulations:)
This commit is contained in:
parent
f56afa7347
commit
d0484100ba
654
package-lock.json
generated
654
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,7 @@
|
||||||
"babel-loader": "^8.0.6",
|
"babel-loader": "^8.0.6",
|
||||||
"babel-plugin-transform-runtime": "^6.23.0",
|
"babel-plugin-transform-runtime": "^6.23.0",
|
||||||
"babel-regenerator-runtime": "^6.5.0",
|
"babel-regenerator-runtime": "^6.5.0",
|
||||||
"copy-webpack-plugin": "^5.0.4",
|
"copy-webpack-plugin": "^5.1.1",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"css-loader": "^3.0.0",
|
"css-loader": "^3.0.0",
|
||||||
"file-loader": "^4.1.0",
|
"file-loader": "^4.1.0",
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
"html-webpack-inline-source-plugin": "0.0.10",
|
"html-webpack-inline-source-plugin": "0.0.10",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"mini-css-extract-plugin": "^0.8.0",
|
"mini-css-extract-plugin": "^0.8.0",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.13.1",
|
||||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||||
"sass-loader": "^7.1.0",
|
"sass-loader": "^7.1.0",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { SimulationRenderer } from '../../simulationRenderer/classes/SimulationRenderer'
|
import { SimulationRenderer } from '../../simulationRenderer/classes/SimulationRenderer'
|
||||||
import { idStore } from '../../simulation/stores/idStore'
|
import { idStore } from '../../simulation/stores/idStore'
|
||||||
import { deleteGate } from '../../simulationRenderer/helpers/deleteGate'
|
import { deleteGate } from '../../simulationRenderer/helpers/deleteGate'
|
||||||
|
import { substract, averege } from '../../vector2/helpers/basic'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to copy the selection of a renderer
|
* Helper to copy the selection of a renderer
|
||||||
|
@ -10,10 +11,12 @@ import { deleteGate } from '../../simulationRenderer/helpers/deleteGate'
|
||||||
export const copy = (renderer: SimulationRenderer) => {
|
export const copy = (renderer: SimulationRenderer) => {
|
||||||
const selected = renderer.getSelected()
|
const selected = renderer.getSelected()
|
||||||
|
|
||||||
|
const center = averege(...selected.map(({ transform }) => transform.position))
|
||||||
|
|
||||||
renderer.wireClipboard = []
|
renderer.wireClipboard = []
|
||||||
renderer.clipboard = selected.map(gate => ({
|
renderer.clipboard = selected.map(gate => ({
|
||||||
name: gate.template.metadata.name,
|
name: gate.template.metadata.name,
|
||||||
position: gate.transform.position
|
position: substract(gate.transform.position, center)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
for (const wire of renderer.simulation.wires) {
|
for (const wire of renderer.simulation.wires) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ export const instantiateGateInitter = (
|
||||||
const gate = renderer.simulation.gates.get(id)
|
const gate = renderer.simulation.gates.get(id)
|
||||||
|
|
||||||
if (gate && gate.data) {
|
if (gate && gate.data) {
|
||||||
gate.data.transform.position = initter.position
|
gate.data.transform.position = add(initter.position, renderer.camera.toWordPostition(Screen.center))
|
||||||
}
|
}
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -63,3 +63,10 @@ export const substract = (vector: vector2, other: vector2) =>
|
||||||
relativeTo(other, vector)
|
relativeTo(other, vector)
|
||||||
|
|
||||||
export const inverse = (vector: vector2) => vector.map(a => 1 / a) as vector2
|
export const inverse = (vector: vector2) => vector.map(a => 1 / a) as vector2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the aritmetic averege of n vectors.
|
||||||
|
*
|
||||||
|
* @param vectors tHe vectors to find the averege of
|
||||||
|
*/
|
||||||
|
export const averege = (...vectors: vector2[]) => multiply(add(...vectors), 1 / vectors.length)
|
Loading…
Reference in a new issue