Skip to content

Commit

Permalink
🚧 ct.3d module
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Aug 14, 2020
1 parent 0a8321f commit 8433008
Show file tree
Hide file tree
Showing 28 changed files with 4,888 additions and 0 deletions.
3,753 changes: 3,753 additions & 0 deletions app/data/ct.libs/3d/includes/pixi.projection.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/data/ct.libs/3d/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ct.camera3d = null;
5 changes: 5 additions & 0 deletions app/data/ct.libs/3d/injects/beforedraw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (this.threeDEnabled && this.threeDOrientation === 'faceCamera') {
this.euler.x = ct.camera3d.euler.x;
this.euler.y = ct.camera3d.euler.y;
this.euler.z = ct.camera3d.euler.z;
}
12 changes: 12 additions & 0 deletions app/data/ct.libs/3d/injects/beforeroomoncreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if (ct.camera3d) {
ct.camera3d.destroy();
}
ct.camera3d = new PIXI.projection.Camera3d();
// Disable alignment by 2D camera
ct.camera3d.isUi = true;
ct.camera3d.position.set(ct.camera.width / 2, ct.camera.height / 2);
ct.camera3d.position3d.set(ct.camera.width / 2, ct.camera.height / 2, ct.room.threeDCameraZ);
ct.camera3d.setPlanes(1000, 10, 10000, false);
ct.pixiApp.stage.addChild(ct.camera3d);
ct.camera3d.room = new PIXI.projection.Container3d();
ct.camera3d.addChild(ct.camera3d.room);
1 change: 1 addition & 0 deletions app/data/ct.libs/3d/injects/htmlbottom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="text/javascript" src="./pixi.projection.js"></script>
24 changes: 24 additions & 0 deletions app/data/ct.libs/3d/injects/onbeforecreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if (this.threeDEnabled) {
this.convertTo3d();
if (this.threeDOrientation === 'xPositive') {
this.euler.y = Math.PI / 2;
} else if (this.threeDOrientation === 'xNegative') {
this.euler.y = -Math.PI / 2;
} else if (this.threeDOrientation === 'yPositive') {
this.euler.x = Math.PI / 2;
} else if (this.threeDOrientation === 'yNegative') {
this.euler.x = -Math.PI / 2;
} else if (this.threeDOrientation === 'zNegative') {
this.euler.x = Math.PI;
} else {
this.euler.x = ct.camera3d.euler.x;
this.euler.y = ct.camera3d.euler.y;
this.euler.z = ct.camera3d.euler.z;
}
if (!ct.room.threeDFlipYZ) {
this.position3d.set(this.x, this.y, this.depth);
} else {
this.position3d.set(this.x, this.depth, this.y);
}
this.position.set(0);
}
3 changes: 3 additions & 0 deletions app/data/ct.libs/3d/injects/oncreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (this.threeDEnabled) {
ct.camera3d.room.addChild(this);
}
58 changes: 58 additions & 0 deletions app/data/ct.libs/3d/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"main": {
"name": "Pseudo-3D",
"tagline": "Create a 3D-ish world from a 2D game!",
"version": "0.0.0",
"authors": [{
"name": "Cosmo Myzrail Gorynych",
"mail": "[email protected]"
}],
"categories": [
"fx"
]
},
"typeExtends": [{
"name": "3D enabled",
"type": "checkbox",
"default": false,
"key": "threeDEnabled"
}, {
"name": "3D orientation",
"type": "radio",
"default": "zPositive",
"key": "threeDOrientation",
"options": [{
"value": "xPositive",
"name": "X positive"
}, {
"value": "xNegative",
"name": "X negative"
}, {
"value": "yPositive",
"name": "Y positive"
}, {
"value": "yNegative",
"name": "Y negative"
}, {
"value": "zPositive",
"name": "Z positive"
}, {
"value": "zNegative",
"name": "Z negative"
}, {
"value": "faceCamera",
"name": "Face camera"
}]
}],
"roomExtends": [{
"name": "Camera Z position",
"type": "number",
"default": 500,
"key": "threeDCameraZ"
}, {
"name": "Flip Y and Z (use it when you design 2D view as a top-down map)",
"type": "checkbox",
"default": false,
"key": "threeDFlipYZ"
}]
}
Loading

0 comments on commit 8433008

Please sign in to comment.