Skip to content

Commit ce5e340

Browse files
committed
init
1 parent 79a8a96 commit ce5e340

File tree

5 files changed

+11
-77
lines changed

5 files changed

+11
-77
lines changed

example/components/collections/container.collection

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ instances {
99
value: "40.0"
1010
type: PROPERTY_TYPE_NUMBER
1111
}
12-
properties {
13-
id: "angle_x"
14-
value: "-30.0"
15-
type: PROPERTY_TYPE_NUMBER
16-
}
17-
properties {
18-
id: "angle_y"
19-
value: "45.0"
20-
type: PROPERTY_TYPE_NUMBER
21-
}
2212
}
2313
}
2414
instances {

example/components/gameobjects/camera.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,6 @@ components {
1616
value: "0.0"
1717
type: PROPERTY_TYPE_NUMBER
1818
}
19-
properties {
20-
id: "angle_x"
21-
value: "0.0"
22-
type: PROPERTY_TYPE_NUMBER
23-
}
24-
properties {
25-
id: "angle_y"
26-
value: "0.0"
27-
type: PROPERTY_TYPE_NUMBER
28-
}
29-
properties {
30-
id: "angle_min"
31-
value: "0.0"
32-
type: PROPERTY_TYPE_NUMBER
33-
}
34-
properties {
35-
id: "angle_max"
36-
value: "0.0"
37-
type: PROPERTY_TYPE_NUMBER
38-
}
3919
}
4020
embedded_components {
4121
id: "camera"

example/scripts/lib/camera.lua

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
local camera = {}
1+
local camera = {}
22

3-
local DISPLAY_WIDTH = sys.get_config_int("display.width")
4-
local DISPLAY_HEIGHT = sys.get_config_int("display.height")
5-
local camera_url = msg.url(".")
6-
local VECTOR_UP = vmath.vector3(0, 1, 0)
7-
local PIVOT = vmath.vector3(0, 1, 0)
3+
local camera_url = msg.url(".")
4+
local VECTOR_UP = vmath.vector3(0, 1, 0)
5+
local PIVOT = vmath.vector3(0, 1, 0)
86

9-
local nv = vmath.vector4(0, 0, -1, 1)
10-
local fv = vmath.vector4(0, 0, 1, 1)
7+
local nv = vmath.vector4(0, 0, -1, 1)
8+
local fv = vmath.vector4(0, 0, 1, 1)
119

1210
function camera.init()
1311
msg.post("@render:", "use_camera_projection")
@@ -29,41 +27,7 @@ function camera.screen_to_viewport(x, y, delta)
2927
end
3028

3129
-- from rendercam
32-
function camera.screen_to_world_2d(x, y, delta, worldz, raw)
33-
-- x, y = camera.screen_to_viewport(x, y, delta)
34-
35-
36-
local projection = go.get(camera_url, "projection")
37-
local view = go.get(camera_url, "view")
38-
local window_width, window_height = window.get_size()
39-
40-
local m = not delta and vmath.inv(projection * view) or vmath.inv(projection)
41-
42-
-- Remap coordinates to range -1 to 1
43-
x1 = (x - window_width * 0.5) / window_width * 2
44-
y1 = (y - window_height * 0.5) / window_height * 2
45-
46-
if delta then
47-
x1 = x1 + 1; y1 = y1 + 1
48-
end
49-
50-
nv.x, nv.y = x1, y1
51-
fv.x, fv.y = x1, y1
52-
local np = m * nv
53-
local fp = m * fv
54-
np = np * (1 / np.w)
55-
fp = fp * (1 / fp.w)
56-
57-
local t = (worldz - 0.1) / (100 - 0.1) -- normalize desired Z to 0-1 from abs_nearZ to abs_farZ
58-
local worldpos = vmath.lerp(t, np, fp)
59-
60-
if raw then
61-
return worldpos.x, worldpos.y, worldpos.z
62-
else
63-
return vmath.vector3(worldpos.x, worldpos.y, worldpos.z)
64-
end -- convert vector4 to vector3
65-
end
66-
30+
-- https://github.com/rgrams/rendercam
6731
function camera.screen_to_world_ray(x, y, raw)
6832
local projection = go.get(camera_url, "projection")
6933

example/scripts/manifold.script

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ function update(self, dt)
3333
for i = 1, query_result_count do
3434
pprint(query_result[i])
3535
-- Offset the position if a collision occurs."
36-
local offset_x = query_result[i].normal_x * query_result[i].depth
37-
local offset_y = query_result[i].normal_y * query_result[i].depth
38-
local offset_z = query_result[i].normal_z * query_result[i].depth
36+
local offset_x = query_result[i].normal.x * query_result[i].depth
37+
local offset_y = query_result[i].normal.y * query_result[i].depth
38+
local offset_z = query_result[i].normal.z * query_result[i].depth
3939

4040
manager.world_position = manager.world_position + vmath.vector3(offset_x, offset_y, offset_z)
4141
end

example/scripts/test.gui_script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function init(self)
33
end
44

55
function on_input(self, action_id, action)
6-
if gui.pick_node(gui.get_node("next_btn"), action.x, action.y) and action.pressed then
6+
if gui.pick_node(gui.get_node("next_btn"), action.x, action.y) and action.pressed and action_id == hash("touch") then
77
msg.post("load:/proxies#load", "next", {})
88
end
99
end

0 commit comments

Comments
 (0)