Skip to content

Commit 0a7d4ac

Browse files
committed
Fix image Y direction.
1 parent 58ef006 commit 0a7d4ac

File tree

2 files changed

+191
-10
lines changed

2 files changed

+191
-10
lines changed

examples/3d-endless-terrain/3d-endless-terrain.json

Lines changed: 191 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@
124124
"name": "assets\\Heightmap.png",
125125
"smoothed": true,
126126
"userAdded": false
127+
},
128+
{
129+
"file": "assets/New image.png",
130+
"kind": "image",
131+
"metadata": "{\"extension\":\".png\",\"pskl\":{}}",
132+
"name": "New image",
133+
"smoothed": true,
134+
"userAdded": false
127135
}
128136
],
129137
"resourceFolders": []
@@ -2237,19 +2245,30 @@
22372245
"windowMask": false
22382246
},
22392247
"objectsGroups": [],
2240-
"variables": [],
2248+
"variables": [
2249+
{
2250+
"name": "CameraElevationAngle",
2251+
"type": "number",
2252+
"value": 90
2253+
},
2254+
{
2255+
"name": "CameraRotationAngle",
2256+
"type": "number",
2257+
"value": 0
2258+
}
2259+
],
22412260
"instances": [
22422261
{
22432262
"angle": 0,
22442263
"customSize": true,
22452264
"depth": 64,
2246-
"height": 500,
2265+
"height": 800,
22472266
"layer": "",
22482267
"name": "NewHeightMap3D",
22492268
"persistentUuid": "644853ac-2a9d-414d-86aa-a9967cf996bd",
2250-
"width": 500,
2251-
"x": 401,
2252-
"y": 105,
2269+
"width": 800,
2270+
"x": 251,
2271+
"y": -35,
22532272
"zOrder": 1,
22542273
"numberProperties": [],
22552274
"stringProperties": [],
@@ -2269,7 +2288,9 @@
22692288
"HeightMapImage": "assets\\Heightmap.png",
22702289
"FieldDimensionX": 257,
22712290
"FieldDimensionY": 257,
2272-
"WhiteValue": 100
2291+
"WhiteValue": 100,
2292+
"ImageOffsetX": 0,
2293+
"ImageOffsetY": 0
22732294
}
22742295
}
22752296
],
@@ -2281,7 +2302,164 @@
22812302
}
22822303
]
22832304
},
2284-
"events": [],
2305+
"events": [
2306+
{
2307+
"colorB": 228,
2308+
"colorG": 176,
2309+
"colorR": 74,
2310+
"creationTime": 0,
2311+
"name": "Camera rotation",
2312+
"source": "",
2313+
"type": "BuiltinCommonInstructions::Group",
2314+
"events": [
2315+
{
2316+
"type": "BuiltinCommonInstructions::Standard",
2317+
"conditions": [
2318+
{
2319+
"type": {
2320+
"value": "DepartScene"
2321+
},
2322+
"parameters": [
2323+
""
2324+
]
2325+
}
2326+
],
2327+
"actions": [
2328+
{
2329+
"type": {
2330+
"value": "ThirdPersonCamera::LookFromDistanceAtPosition"
2331+
},
2332+
"parameters": [
2333+
"",
2334+
"SceneWindowWidth() / 2",
2335+
"SceneWindowHeight() / 2",
2336+
"1200",
2337+
"0",
2338+
"90",
2339+
"",
2340+
""
2341+
]
2342+
}
2343+
]
2344+
},
2345+
{
2346+
"type": "BuiltinCommonInstructions::Standard",
2347+
"conditions": [],
2348+
"actions": [],
2349+
"events": [
2350+
{
2351+
"type": "BuiltinCommonInstructions::Standard",
2352+
"conditions": [
2353+
{
2354+
"type": {
2355+
"value": "MouseButtonPressed"
2356+
},
2357+
"parameters": [
2358+
"",
2359+
"Left"
2360+
]
2361+
},
2362+
{
2363+
"type": {
2364+
"value": "BuiltinCommonInstructions::Once"
2365+
},
2366+
"parameters": []
2367+
}
2368+
],
2369+
"actions": [
2370+
{
2371+
"type": {
2372+
"value": "MousePointerLock::RequestPointerLock"
2373+
},
2374+
"parameters": [
2375+
"",
2376+
""
2377+
]
2378+
}
2379+
]
2380+
},
2381+
{
2382+
"type": "BuiltinCommonInstructions::Standard",
2383+
"conditions": [
2384+
{
2385+
"type": {
2386+
"value": "MouseButtonReleased"
2387+
},
2388+
"parameters": [
2389+
"",
2390+
"Left"
2391+
]
2392+
}
2393+
],
2394+
"actions": [
2395+
{
2396+
"type": {
2397+
"value": "MousePointerLock::ExitPointerLock"
2398+
},
2399+
"parameters": [
2400+
"",
2401+
""
2402+
]
2403+
}
2404+
]
2405+
},
2406+
{
2407+
"type": "BuiltinCommonInstructions::Standard",
2408+
"conditions": [
2409+
{
2410+
"type": {
2411+
"value": "MouseButtonPressed"
2412+
},
2413+
"parameters": [
2414+
"",
2415+
"Left"
2416+
]
2417+
}
2418+
],
2419+
"actions": [
2420+
{
2421+
"type": {
2422+
"value": "SetNumberVariable"
2423+
},
2424+
"parameters": [
2425+
"CameraElevationAngle",
2426+
"=",
2427+
"clamp(CameraElevationAngle + MousePointerLock::MovementY() / 5, 15, 89)"
2428+
]
2429+
},
2430+
{
2431+
"type": {
2432+
"value": "SetNumberVariable"
2433+
},
2434+
"parameters": [
2435+
"CameraRotationAngle",
2436+
"+",
2437+
"MousePointerLock::MovementX() / 5"
2438+
]
2439+
},
2440+
{
2441+
"type": {
2442+
"value": "ThirdPersonCamera::LookFromDistanceAtPosition"
2443+
},
2444+
"parameters": [
2445+
"",
2446+
"SceneWindowWidth() / 2",
2447+
"SceneWindowHeight() / 2",
2448+
"1200",
2449+
"CameraRotationAngle",
2450+
"CameraElevationAngle",
2451+
"",
2452+
""
2453+
]
2454+
}
2455+
]
2456+
}
2457+
]
2458+
}
2459+
],
2460+
"parameters": []
2461+
}
2462+
],
22852463
"layers": [
22862464
{
22872465
"ambientLightColorB": 200,
@@ -2429,7 +2607,7 @@
24292607
" this.mesh.rotation.order = 'ZYX';",
24302608
" this.mesh.position.x = 32;",
24312609
" this.mesh.position.y = 32;",
2432-
" //this.mesh.scale.y = -1;",
2610+
" this.mesh.scale.y = -1;",
24332611
" object.get3DRendererObject().add(this.mesh);",
24342612
" // // Ensure a forward compatibility when vertexColors will be set to true",
24352613
" // // in the engine to allow to tint 3D custom objects.",
@@ -2488,7 +2666,7 @@
24882666
" * @returns {integer}",
24892667
" */",
24902668
" getVerticeZIndex(indexX, indexY) {",
2491-
" return 2 + 3 * (indexX + (this.dimY - 1 - indexY) * this.dimX);",
2669+
" return 2 + 3 * (indexX + indexY * this.dimX);",
24922670
" }",
24932671
"",
24942672
" /**",
@@ -2586,6 +2764,9 @@
25862764
" // Jolt.HeightFieldShapeConstantValues.prototype.cNoCollisionValue;",
25872765
" }",
25882766
" const shape = shapeSettings.Create().Get();",
2767+
" Jolt.destroy(shapeSettings);",
2768+
" const scaledShape = shape.ScaleShape(_sharedData.getVec3(1, 1, -1)).Get();",
2769+
" ",
25892770
"",
25902771
" // console.log(",
25912772
" // \"Shape local AABB\",",
@@ -2602,7 +2783,7 @@
26022783
" const rotation = this._getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1));",
26032784
"",
26042785
" // console.log(\"position\", position.GetX(), position.GetY(), position.GetZ());",
2605-
" const creationSettings = new Jolt.BodyCreationSettings(shape, position, rotation, Jolt.EMotionType_Static, physics.getBodyLayer());",
2786+
" const creationSettings = new Jolt.BodyCreationSettings(scaledShape, position, rotation, Jolt.EMotionType_Static, physics.getBodyLayer());",
26062787
" const body = _sharedData.bodyInterface.CreateBody(creationSettings);",
26072788
" Jolt.destroy(creationSettings);",
26082789
" _sharedData.bodyInterface.AddBody(",
3.88 KB
Loading

0 commit comments

Comments
 (0)