Working with Phases Aligned
This commit is contained in:
1 parent
468ef8d0c6
commit
eca3a41764
3 files changed
+60
-29
No files matched your search
@@ -203,7 +203,7 @@ function newFloatingLayer () {
|
||||
for (let i = 0; i < invisibleFloatingObjects.length; i++) {
|
||||
let floatingObject = invisibleFloatingObjects[i]
|
||||
|
||||
if (floatingObject.isFrozen === false && floatingObject.isTensed === false) {
|
||||
if (floatingObject.isFrozen === false) {
|
||||
visibleFloatingObjects.push(floatingObject)
|
||||
invisibleFloatingObjects.splice(i, 1) // Delete item from array.
|
||||
return // Only one at the time.
|
||||
@@ -215,7 +215,7 @@ function newFloatingLayer () {
|
||||
for (let i = 0; i < visibleFloatingObjects.length; i++) {
|
||||
let floatingObject = visibleFloatingObjects[i]
|
||||
|
||||
if (floatingObject.isFrozen === true || floatingObject.isTensed === true) {
|
||||
if (floatingObject.isFrozen === true) {
|
||||
invisibleFloatingObjects.push(floatingObject)
|
||||
visibleFloatingObjects.splice(i, 1) // Delete item from array.
|
||||
return // Only one at the time.
|
||||
@@ -429,9 +429,10 @@ function newFloatingLayer () {
|
||||
}
|
||||
|
||||
/* We add the force vector to the speed vector */
|
||||
|
||||
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x + forceVector.x
|
||||
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y + forceVector.y
|
||||
if (isNaN(forceVector.x) === false && isNaN(forceVector.y) === false) {
|
||||
floatingObject.currentSpeed.x = floatingObject.currentSpeed.x + forceVector.x
|
||||
floatingObject.currentSpeed.y = floatingObject.currentSpeed.y + forceVector.y
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] gravityForce -> err= ' + err.stack) }
|
||||
@@ -490,9 +491,10 @@ function newFloatingLayer () {
|
||||
}
|
||||
|
||||
/* We substract the force vector to the speed vector of the current floatingObject */
|
||||
|
||||
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
|
||||
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
|
||||
if (isNaN(forceVector.x) === false && isNaN(forceVector.y) === false) {
|
||||
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
|
||||
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -608,8 +610,10 @@ function newFloatingLayer () {
|
||||
|
||||
/* We substract the force vector to the speed vector of the current floatingObject */
|
||||
|
||||
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
|
||||
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
|
||||
if (isNaN(forceVector.x) === false && isNaN(forceVector.y) === false) {
|
||||
floatingObject1.currentSpeed.x = floatingObject1.currentSpeed.x - forceVector.x
|
||||
floatingObject1.currentSpeed.y = floatingObject1.currentSpeed.y - forceVector.y
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -186,17 +186,36 @@ function newFloatingObject () {
|
||||
let parentChildren = canvas.strategySpace.workspace.nodeChildren.childrenCount(parent, thisObject.payload.node)
|
||||
let axisCount = parentChildren.childrenCount
|
||||
let axisIndex = parentChildren.childIndex
|
||||
let baseAngle = 0
|
||||
|
||||
if (parent.payload.chainParent !== undefined) {
|
||||
if (axisIndex === undefined) {
|
||||
axisCount = 1
|
||||
axisIndex = axisCount
|
||||
}
|
||||
|
||||
if (parent.payload.chainParent !== undefined && parent.payload.angle !== undefined) {
|
||||
axisCount++
|
||||
axisIndex++
|
||||
baseAngle = parent.payload.angle + 180
|
||||
}
|
||||
|
||||
let angleStep = 360 / axisCount
|
||||
let myAngle = axisIndex * axisCount
|
||||
|
||||
thisObject.container.frame.position.x = parent.payload.position.x + distanceToChainParent * Math.cos(toRadians(myAngle))
|
||||
thisObject.container.frame.position.y = parent.payload.position.y + distanceToChainParent * Math.sin(toRadians(myAngle))
|
||||
thisObject.payload.angle = baseAngle + (axisIndex - 1) * angleStep
|
||||
if (thisObject.payload.angle >= 360) {
|
||||
thisObject.payload.angle = thisObject.payload.angle - 360
|
||||
}
|
||||
|
||||
newPosition = {
|
||||
x: parent.payload.position.x + distanceToChainParent * Math.cos(toRadians(thisObject.payload.angle)),
|
||||
y: parent.payload.position.y + distanceToChainParent * Math.sin(toRadians(thisObject.payload.angle))
|
||||
}
|
||||
if (isNaN(newPosition.x) === false) {
|
||||
thisObject.container.frame.position.x = newPosition.x
|
||||
}
|
||||
if (isNaN(newPosition.y) === false) {
|
||||
thisObject.container.frame.position.y = newPosition.y
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,19 +371,15 @@ function newFloatingObject () {
|
||||
let position = {}
|
||||
|
||||
if (thisObject.payload.position === undefined) {
|
||||
if (thisObject.payload.chainParent !== undefined) {
|
||||
/* if (thisObject.payload.chainParent !== undefined) {
|
||||
position.x = thisObject.payload.chainParent.payload.position.x + 250
|
||||
if (thisObject.payload.node.type === thisObject.payload.chainParent.type) {
|
||||
position.y = thisObject.payload.chainParent.payload.position.y
|
||||
} else {
|
||||
position.y = thisObject.payload.chainParent.payload.position.y + Math.floor((Math.random() * (1000) - 500))
|
||||
}
|
||||
} else {
|
||||
position = {
|
||||
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
|
||||
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
|
||||
}
|
||||
position.y = thisObject.payload.chainParent.payload.position.y
|
||||
} else { */
|
||||
position = {
|
||||
x: Math.floor((Math.random() * (200) - 100)) + arroundPoint.x,
|
||||
y: Math.floor((Math.random() * (200) - 100)) + arroundPoint.y
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
position = {
|
||||
x: thisObject.payload.position.x,
|
||||
@@ -416,3 +431,4 @@ function newFloatingObject () {
|
||||
function updateRadius () {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,9 +290,14 @@ function newNodeChildren () {
|
||||
}
|
||||
for (let i = 0; i < parentNode.phases.length; i++) {
|
||||
let child = parentNode.phases[i]
|
||||
response.childrenCount++
|
||||
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
if (childNode.payload.chainParent !== undefined) {
|
||||
if (childNode.payload.chainParent.id === parentNode.id) {
|
||||
response.childrenCount++
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return response
|
||||
@@ -305,9 +310,14 @@ function newNodeChildren () {
|
||||
}
|
||||
for (let i = 0; i < parentNode.phases.length; i++) {
|
||||
let child = parentNode.phases[i]
|
||||
response.childrenCount++
|
||||
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
if (childNode.payload.chainParent !== undefined) {
|
||||
if (childNode.payload.chainParent.id === parentNode.id) {
|
||||
response.childrenCount++
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return response
|
||||
@@ -378,3 +388,4 @@ function newNodeChildren () {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user