-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_object3d_mesh.go
229 lines (187 loc) · 6.87 KB
/
gen_object3d_mesh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
package three
// Code generated by go generate; DO NOT EDIT.
//
// using the following cmd:
// object3d_method_generator -typeName Mesh -typeSlug mesh
import "syscall/js"
// Compile-time check that this type implements Object3D interface.
var _ Object3D = Mesh{}
// readonly – Unique number for this object instance.
func (obj Mesh) ID() int {
return obj.Get("id").Int()
}
// ApplyMatrix4 applies the matrix transform to the object and updates the object's position, rotation and scale.
func (obj Mesh) ApplyMatrix4(matrix Matrix4) {
obj.Call("applyMatrix4", matrix.Value)
}
// ApplyQuaternion applies the rotation represented by q to the object.
func (obj Mesh) ApplyQuaternion(q Quaternion) {
obj.Call("applyQuaternion", q.Value)
}
// Add object as child of this object. An arbitrary number of objects may be added.
// Any current parent on an object passed in here will be removed, since an object can have at most one parent.
func (obj Mesh) Add(m Object3D) {
obj.Value.Call("add", m.getInternalObject())
}
// Attach adds m as a child of this, while maintaining m's world transform.
func (obj Mesh) Attach(m Object3D) {
obj.Value.Call("attach", m.getInternalObject())
}
// Clear removes all child objects.
func (obj Mesh) Clear() {
obj.Value.Call("clear")
}
// Remove m as child of this object. An arbitrary number of objects may be removed.
func (obj Mesh) Remove(m Object3D) {
obj.Value.Call("remove", m.getInternalObject())
}
// RemoveFromParent removes this object from its current parent.
func (obj Mesh) RemoveFromParent() {
obj.Value.Call("removeFromParent")
}
// GetObjectById searches through an object and its children, starting with the object itself, and returns the first with a matching id.
func (obj Mesh) GetObjectById(id int) js.Value {
return obj.Call("getObjectById", id)
}
// Copy the given m into this object. Note: event listeners and user-defined callbacks (.onAfterRender and .onBeforeRender) are not copied.
func (obj Mesh) Copy(m Object3D, recursive bool) Mesh {
return Mesh{Value: obj.Value.Call("copy", m.getInternalObject(), recursive)}
}
func (obj Mesh) Clone(recursive bool) Mesh {
return Mesh{Value: obj.Value.Call("clone", recursive)}
}
func (obj Mesh) ToJSON() js.Value {
return obj.Value.Call("toJSON")
}
func (obj Mesh) getInternalObject() js.Value {
return obj.Value
}
// Updates the local transform.
func (obj Mesh) UpdateMatrix() {
obj.Call("updateMatrix")
}
// Rotate an object along an axis in object space. The axis is assumed to be normalized.
// axis is a normalized vector in object space.
func (obj Mesh) RotateOnAxis(angle float64, axis Vector3) (this Mesh) {
obj.Call("rotateOnAxis", axis.Value, angle)
return obj
}
// Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent.
// axis is a normalized vector in world space.
func (obj Mesh) RotateOnWorldAxis(angle float64, axis Vector3) (this Mesh) {
obj.Call("rotateOnAxis", axis.Value, angle)
return obj
}
// RotateX rotates object around x axis in local space.
func (obj Mesh) RotateX(rad float64) (this Mesh) {
obj.Call("rotateX", rad)
return obj
}
// RotateY rotates object around y axis in local space.
func (obj Mesh) RotateY(rad float64) (this Mesh) {
obj.Call("rotateY", rad)
return obj
}
// RotateZ rotates object around z axis in local space.
func (obj Mesh) RotateZ(rad float64) (this Mesh) {
obj.Call("rotateZ", rad)
return obj
}
// Calls setFromAxisAngle( axis, angle ) on the .quaternion.
func (obj Mesh) SetRotationFromAxisAngle(angle float64, axis Vector3) {
obj.Call("setRotationFromAxisAngle", axis.Value, angle)
}
// Calls setRotationFromEuler(euler) on the .quaternion.
func (obj Mesh) SetRotationFromEuler(euler Euler) {
obj.Call("setRotationFromEuler", euler.Value)
}
// Calls setFromRotationMatrix(m) on the .quaternion.
func (obj Mesh) SetRotationFromMatrix(m Matrix4) {
obj.Call("setRotationFromMatrix", m.Value)
}
// Copy the given quaternion into .quaternion.
func (obj Mesh) SetRotationFromQuaternion(q Quaternion) {
obj.Call("setRotationFromQuaternion", q.Value)
}
func (obj Mesh) SetPosition(v Vector3) {
obj.Get("position").Call("copy", v.Value)
}
func (obj Mesh) GetPosition() Vector3 {
return Vector3{
Value: obj.Get("position"),
}
}
func (obj Mesh) GetRotation() Euler {
return Euler{
Value: obj.Get("rotation"),
}
}
// Returns a vector representing the position of the object in world space.
// The result is copied into dst.
func (obj Mesh) GetWorldPosition(dst Vector3) Vector3 {
return Vector3{
Value: obj.Call("getWorldPosition", dst.Value),
}
}
// Returns a vector representing the direction of object's positive z-axis in world space.
// The result is copied into dst.
func (obj Mesh) GetWorldDirection(dst Vector3) Vector3 {
return Vector3{
Value: obj.Call("getWorldDirection", dst.Value),
}
}
// Returns a vector of the scaling factors applied to the object for each axis in world space.
// The result is copied into dst.
func (obj Mesh) GetWorldScale(dst Vector3) Vector3 {
return Vector3{
Value: obj.Call("getWorldScale", dst.Value),
}
}
// Returns a quaternion representing the rotation of the object in world space.
// The result is copied into dst.
func (obj Mesh) GetWorldQuaternion(dst Quaternion) Quaternion {
return Quaternion{
Value: obj.Call("getWorldDirection", dst.Value),
}
}
// Rotates the object to face a point in world space.
func (obj Mesh) LookAt(target Vector3) {
obj.Call("lookAt", target.Value)
}
// Rotates the object to face a point in world space.
func (obj Mesh) LookAtCoords(x, y, z float64) {
obj.Call("lookAt", x, y, z)
}
// Converts vec from this object's local space to world space.
func (obj Mesh) LocalToWorld(vec Vector3) Vector3 {
return Vector3{
Value: obj.Call("localToWorld", vec.Value),
}
}
// Converts vec from world space to this object's local space.
// vec represents position in world space.
func (obj Mesh) WorldToLocal(vec Vector3) Vector3 {
return Vector3{
Value: obj.Call("worldToLocal", vec.Value),
}
}
// Translate an object by distance along an axis in object space. The axis is assumed to be normalized.
func (obj Mesh) TranslateOnAxis(distance float64, axis Vector3) {
obj.Call("translateOnAxis", axis.Value, distance)
}
// Translates object along x axis in object space by distance units.
func (obj Mesh) TranslateX(distance float64) {
obj.Call("translateX", distance)
}
// Translates object along y axis in object space by distance units.
func (obj Mesh) TranslateY(distance float64) {
obj.Call("translateY", distance)
}
// Translates object along z axis in object space by distance units.
func (obj Mesh) TranslateZ(distance float64) {
obj.Call("translateZ", distance)
}
// Abstract (empty) method to get intersections between a casted ray and this object. Subclasses such as Mesh, Line, and Points implement this method in order to use raycasting.
func (obj Mesh) Raycast(rc Raycaster, intersects js.Value) {
obj.Value.Call("raycast", rc.Value, intersects)
}