@defold-typescript/types 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-availability.json +117 -0
- package/api-signatures.json +586 -480
- package/examples/translations.json +356 -180
- package/generated/b2d_body.d.ts +7 -4
- package/generated/b2d_shape.d.ts +23 -1
- package/generated/buffer.d.ts +34 -19
- package/generated/camera.d.ts +3 -2
- package/generated/collectionfactory.d.ts +17 -12
- package/generated/collectionproxy.d.ts +2 -2
- package/generated/compute.d.ts +1 -1
- package/generated/factory.d.ts +2 -1
- package/generated/go.d.ts +150 -91
- package/generated/graphics.d.ts +54 -0
- package/generated/gui.d.ts +117 -71
- package/generated/html5.d.ts +4 -2
- package/generated/http.d.ts +8 -2
- package/generated/image.d.ts +24 -15
- package/generated/kinds/gui-script.d.ts +1 -0
- package/generated/kinds/render-script.d.ts +1 -0
- package/generated/kinds/script.d.ts +1 -0
- package/generated/material.d.ts +1 -1
- package/generated/model.d.ts +41 -7
- package/generated/particlefx.d.ts +1 -1
- package/generated/physics.d.ts +29 -20
- package/generated/profiler.d.ts +10 -3
- package/generated/render.d.ts +293 -111
- package/generated/resource.d.ts +243 -226
- package/generated/socket.d.ts +33 -18
- package/generated/sound.d.ts +6 -5
- package/generated/sprite.d.ts +9 -1
- package/generated/sys.d.ts +44 -27
- package/generated/tilemap.d.ts +25 -19
- package/generated/timer.d.ts +33 -24
- package/generated/versions/defold-1.12.4/buffer.d.ts +34 -19
- package/generated/versions/defold-1.12.4/camera.d.ts +3 -2
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +17 -12
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +2 -1
- package/generated/versions/defold-1.12.4/go.d.ts +150 -91
- package/generated/versions/defold-1.12.4/graphics.d.ts +2 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +109 -69
- package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
- package/generated/versions/defold-1.12.4/http.d.ts +8 -2
- package/generated/versions/defold-1.12.4/image.d.ts +24 -15
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/model.d.ts +41 -7
- package/generated/versions/defold-1.12.4/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +29 -20
- package/generated/versions/defold-1.12.4/profiler.d.ts +10 -3
- package/generated/versions/defold-1.12.4/render.d.ts +292 -110
- package/generated/versions/defold-1.12.4/resource.d.ts +243 -226
- package/generated/versions/defold-1.12.4/socket.d.ts +33 -18
- package/generated/versions/defold-1.12.4/sound.d.ts +6 -5
- package/generated/versions/defold-1.12.4/sprite.d.ts +9 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +44 -27
- package/generated/versions/defold-1.12.4/tilemap.d.ts +25 -19
- package/generated/versions/defold-1.12.4/timer.d.ts +33 -24
- package/generated/versions/defold-1.12.4/vmath.d.ts +18 -10
- package/generated/versions/defold-1.12.4/window.d.ts +5 -3
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +7 -4
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +23 -1
- package/generated/versions/defold-1.13.0/buffer.d.ts +34 -19
- package/generated/versions/defold-1.13.0/camera.d.ts +3 -2
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +17 -12
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.0/compute.d.ts +1 -1
- package/generated/versions/defold-1.13.0/factory.d.ts +2 -1
- package/generated/versions/defold-1.13.0/go.d.ts +150 -91
- package/generated/versions/defold-1.13.0/graphics.d.ts +50 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +109 -69
- package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
- package/generated/versions/defold-1.13.0/http.d.ts +8 -2
- package/generated/versions/defold-1.13.0/image.d.ts +24 -15
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/material.d.ts +1 -1
- package/generated/versions/defold-1.13.0/model.d.ts +41 -7
- package/generated/versions/defold-1.13.0/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +29 -20
- package/generated/versions/defold-1.13.0/profiler.d.ts +10 -3
- package/generated/versions/defold-1.13.0/render.d.ts +293 -111
- package/generated/versions/defold-1.13.0/resource.d.ts +243 -226
- package/generated/versions/defold-1.13.0/socket.d.ts +33 -18
- package/generated/versions/defold-1.13.0/sound.d.ts +6 -5
- package/generated/versions/defold-1.13.0/sprite.d.ts +9 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +44 -27
- package/generated/versions/defold-1.13.0/tilemap.d.ts +25 -19
- package/generated/versions/defold-1.13.0/timer.d.ts +33 -24
- package/generated/versions/defold-1.13.0/vmath.d.ts +18 -10
- package/generated/versions/defold-1.13.0/window.d.ts +5 -3
- package/generated/vmath.d.ts +18 -10
- package/generated/window.d.ts +5 -3
- package/index.d.ts +1 -0
- package/package.json +2 -1
- package/scripts/generate-api-signatures.ts +2 -1
- package/scripts/prose-constants.ts +96 -0
- package/scripts/regen.ts +6 -2
- package/src/api-doc.ts +8 -0
- package/src/component-properties.d.ts +33 -0
- package/src/core-types.ts +4 -2
- package/src/custom-messages.d.ts +4 -3
- package/src/doc-comment.ts +247 -43
- package/src/emit-dts.ts +958 -57
- package/src/engine-globals.d.ts +2 -2
- package/src/example-store.ts +26 -0
- package/src/go-overloads.d.ts +11 -10
- package/src/index.ts +9 -0
- package/src/param-correction-provenance.ts +67 -0
- package/src/render-overloads.d.ts +15 -17
- package/src/script-api.ts +3 -1
package/generated/resource.d.ts
CHANGED
|
@@ -18,20 +18,28 @@ declare global {
|
|
|
18
18
|
* @param path - optional resource path string to the resource
|
|
19
19
|
* @returns a path hash to the binary version of the resource
|
|
20
20
|
* @example
|
|
21
|
+
* Load an atlas and set it to a sprite:
|
|
21
22
|
* ```ts
|
|
22
23
|
* // Load an atlas and set it to a sprite:
|
|
23
|
-
* go.property("my_atlas", resource.atlas("/atlas.atlas"));
|
|
24
|
-
*
|
|
25
24
|
* export default defineScript({
|
|
25
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
26
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
27
|
+
* properties: { my_atlas: resource.atlas("/atlas.atlas") },
|
|
28
|
+
*
|
|
26
29
|
* init(self) {
|
|
27
30
|
* go.set("#sprite", "image", self.my_atlas);
|
|
28
31
|
* },
|
|
29
32
|
* });
|
|
30
|
-
*
|
|
33
|
+
* ```
|
|
34
|
+
* @example
|
|
35
|
+
* Load an atlas and set it to a gui:
|
|
36
|
+
* ```ts
|
|
31
37
|
* // Load an atlas and set it to a gui:
|
|
32
|
-
* go.property("my_atlas", resource.atlas("/atlas.atlas"));
|
|
33
|
-
*
|
|
34
38
|
* export default defineScript({
|
|
39
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
40
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
41
|
+
* properties: { my_atlas: resource.atlas("/atlas.atlas") },
|
|
42
|
+
*
|
|
35
43
|
* init(self) {
|
|
36
44
|
* go.set("#gui", "textures", self.my_atlas, { key: "my_atlas" });
|
|
37
45
|
* },
|
|
@@ -53,9 +61,11 @@ declare global {
|
|
|
53
61
|
* @example
|
|
54
62
|
* ```ts
|
|
55
63
|
* // Set a unique buffer it to a sprite:
|
|
56
|
-
* go.property("my_buffer", resource.buffer("/cube.buffer"));
|
|
57
|
-
*
|
|
58
64
|
* export default defineScript({
|
|
65
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
66
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
67
|
+
* properties: { my_buffer: resource.buffer("/cube.buffer") },
|
|
68
|
+
*
|
|
59
69
|
* init(self) {
|
|
60
70
|
* go.set("#mesh", "vertices", self.my_buffer);
|
|
61
71
|
* },
|
|
@@ -78,109 +88,67 @@ declare global {
|
|
|
78
88
|
* @param path - The path to the resource.
|
|
79
89
|
* @param table - A table containing info about how to create the atlas. Supported entries:
|
|
80
90
|
*
|
|
81
|
-
* -
|
|
82
|
-
*
|
|
83
|
-
* `texture`
|
|
91
|
+
* - `texture`
|
|
84
92
|
* string | hash the path to the texture resource, e.g "/main/my_texture.texturec"
|
|
85
93
|
*
|
|
86
|
-
* -
|
|
87
|
-
*
|
|
88
|
-
* `animations`
|
|
94
|
+
* - `animations`
|
|
89
95
|
* table a list of the animations in the atlas. Supports the following fields:
|
|
90
96
|
*
|
|
91
|
-
* -
|
|
92
|
-
*
|
|
93
|
-
* `id`
|
|
97
|
+
* - `id`
|
|
94
98
|
* string the id of the animation, used in e.g sprite.play_animation
|
|
95
99
|
*
|
|
96
|
-
* -
|
|
97
|
-
*
|
|
98
|
-
* `width`
|
|
100
|
+
* - `width`
|
|
99
101
|
* number the width of the animation
|
|
100
102
|
*
|
|
101
|
-
* -
|
|
102
|
-
*
|
|
103
|
-
* `height`
|
|
103
|
+
* - `height`
|
|
104
104
|
* number the height of the animation
|
|
105
105
|
*
|
|
106
|
-
* -
|
|
107
|
-
*
|
|
108
|
-
* `frame_start`
|
|
106
|
+
* - `frame_start`
|
|
109
107
|
* number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
|
|
110
108
|
*
|
|
111
|
-
* -
|
|
112
|
-
*
|
|
113
|
-
* `frame_end`
|
|
109
|
+
* - `frame_end`
|
|
114
110
|
* number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
|
|
115
111
|
*
|
|
116
|
-
* -
|
|
117
|
-
*
|
|
118
|
-
* `playback`
|
|
112
|
+
* - `playback`
|
|
119
113
|
* constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
|
|
120
114
|
*
|
|
121
|
-
* -
|
|
122
|
-
*
|
|
123
|
-
* `fps`
|
|
115
|
+
* - `fps`
|
|
124
116
|
* number optional fps of the animation, the default value is 30
|
|
125
117
|
*
|
|
126
|
-
* -
|
|
127
|
-
*
|
|
128
|
-
* `flip_vertical`
|
|
118
|
+
* - `flip_vertical`
|
|
129
119
|
* boolean optional flip the animation vertically, the default value is false
|
|
130
120
|
*
|
|
131
|
-
* -
|
|
132
|
-
*
|
|
133
|
-
* `flip_horizontal`
|
|
121
|
+
* - `flip_horizontal`
|
|
134
122
|
* boolean optional flip the animation horizontally, the default value is false
|
|
135
123
|
*
|
|
136
|
-
* -
|
|
137
|
-
*
|
|
138
|
-
* `geometries`
|
|
124
|
+
* - `geometries`
|
|
139
125
|
* table A list of the geometries that should map to the texture data. Supports the following fields:
|
|
140
126
|
*
|
|
141
|
-
* -
|
|
142
|
-
*
|
|
143
|
-
* `id`
|
|
127
|
+
* - `id`
|
|
144
128
|
* string The name of the geometry. Used when matching animations between multiple atlases
|
|
145
129
|
*
|
|
146
|
-
* -
|
|
147
|
-
*
|
|
148
|
-
* `width`
|
|
130
|
+
* - `width`
|
|
149
131
|
* number The width of the image the sprite geometry represents
|
|
150
132
|
*
|
|
151
|
-
* -
|
|
152
|
-
*
|
|
153
|
-
* `height`
|
|
133
|
+
* - `height`
|
|
154
134
|
* number The height of the image the sprite geometry represents
|
|
155
135
|
*
|
|
156
|
-
* -
|
|
157
|
-
*
|
|
158
|
-
* `pivot_x`
|
|
136
|
+
* - `pivot_x`
|
|
159
137
|
* number The pivot x value of the image in unit coords. (0,0) is upper left corner, (1,1) is bottom right. Default is 0.5.
|
|
160
138
|
*
|
|
161
|
-
* -
|
|
162
|
-
*
|
|
163
|
-
* `pivot_y`
|
|
139
|
+
* - `pivot_y`
|
|
164
140
|
* number The pivot y value of the image in unit coords. (0,0) is upper left corner, (1,1) is bottom right. Default is 0.5.
|
|
165
141
|
*
|
|
166
|
-
* -
|
|
167
|
-
*
|
|
168
|
-
* `rotated`
|
|
142
|
+
* - `rotated`
|
|
169
143
|
* boolean Whether the image is rotated 90 degrees counter-clockwise in the atlas. This affects UV coordinate generation for proper rendering. Default is false.
|
|
170
144
|
*
|
|
171
|
-
* -
|
|
172
|
-
*
|
|
173
|
-
* `vertices`
|
|
145
|
+
* - `vertices`
|
|
174
146
|
* table a list of the vertices in image space of the geometry in the form {px0, py0, px1, py1, ..., pxn, pyn}
|
|
175
147
|
*
|
|
176
|
-
* -
|
|
177
|
-
*
|
|
178
|
-
* `uvs`
|
|
148
|
+
* - `uvs`
|
|
179
149
|
* table a list of the uv coordinates in image space of the geometry in the form of {u0, v0, u1, v1, ..., un, vn}.
|
|
180
150
|
*
|
|
181
|
-
* -
|
|
182
|
-
*
|
|
183
|
-
* `indices`
|
|
151
|
+
* - `indices`
|
|
184
152
|
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
185
153
|
* @returns Returns the atlas resource path
|
|
186
154
|
* @example
|
|
@@ -233,7 +201,7 @@ declare global {
|
|
|
233
201
|
* });
|
|
234
202
|
* ```
|
|
235
203
|
*/
|
|
236
|
-
function create_atlas(path: string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?:
|
|
204
|
+
function create_atlas(path: string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean }[]; geometries?: { id?: string; width?: number; height?: number; pivot_x?: number; pivot_y?: number; rotated?: boolean }[]; vertices?: number[]; uvs?: number[]; indices?: number[] }): Hash;
|
|
237
205
|
/**
|
|
238
206
|
* This function creates a new buffer resource that can be used in the same way as any buffer created during build time.
|
|
239
207
|
* The function requires a valid buffer created from either buffer.create or another pre-existing buffer resource.
|
|
@@ -247,17 +215,14 @@ declare global {
|
|
|
247
215
|
* @param path - The path to the resource.
|
|
248
216
|
* @param table - A table containing info about how to create the buffer. Supported entries:
|
|
249
217
|
*
|
|
250
|
-
* -
|
|
251
|
-
*
|
|
252
|
-
* `buffer`
|
|
218
|
+
* - `buffer`
|
|
253
219
|
* buffer the buffer to bind to this resource
|
|
254
220
|
*
|
|
255
|
-
* -
|
|
256
|
-
*
|
|
257
|
-
* `transfer_ownership`
|
|
221
|
+
* - `transfer_ownership`
|
|
258
222
|
* boolean optional flag to determine whether or not the resource should take over ownership of the buffer object (default true)
|
|
259
223
|
* @returns Returns the buffer resource path
|
|
260
224
|
* @example
|
|
225
|
+
* Create a buffer object and bind it to a buffer resource
|
|
261
226
|
* ```ts
|
|
262
227
|
* // Create a buffer object and bind it to a buffer resource
|
|
263
228
|
* export default defineScript({
|
|
@@ -285,15 +250,18 @@ declare global {
|
|
|
285
250
|
* const stream = buffer.get_stream(buffer_handle, hash("position"));
|
|
286
251
|
*
|
|
287
252
|
* // transfer vertex data to buffer
|
|
288
|
-
*
|
|
289
|
-
* stream[k] =
|
|
290
|
-
* }
|
|
253
|
+
* positions.forEach((value, k) => {
|
|
254
|
+
* stream[k] = value;
|
|
255
|
+
* });
|
|
291
256
|
*
|
|
292
257
|
* const my_buffer = resource.create_buffer("/my_buffer.bufferc", { buffer: buffer_handle });
|
|
293
258
|
* go.set("/go#mesh", "vertices", my_buffer);
|
|
294
259
|
* },
|
|
295
260
|
* });
|
|
296
|
-
*
|
|
261
|
+
* ```
|
|
262
|
+
* @example
|
|
263
|
+
* Create a buffer resource from existing resource
|
|
264
|
+
* ```ts
|
|
297
265
|
* // Create a buffer resource from existing resource
|
|
298
266
|
* export default defineScript({
|
|
299
267
|
* init() {
|
|
@@ -326,6 +294,11 @@ declare global {
|
|
|
326
294
|
* export default defineScript({
|
|
327
295
|
* init() {
|
|
328
296
|
* // create a new sound resource, given the initial chunk of the file
|
|
297
|
+
* const [data] = sys.load_resource("/sounds/music_header.oggc");
|
|
298
|
+
* if (data === undefined) {
|
|
299
|
+
* return;
|
|
300
|
+
* }
|
|
301
|
+
* const filesize = 1048576;
|
|
329
302
|
* const relative_path = "/a/unique/resource/name.oggc";
|
|
330
303
|
* const hash = resource.create_sound_data(relative_path, { data, filesize, partial: true });
|
|
331
304
|
* go.set("#music", "sound", hash); // override the previous sound resource
|
|
@@ -449,7 +422,9 @@ declare global {
|
|
|
449
422
|
* if graphics.TEXTURE_TYPE_3D ~= nil then
|
|
450
423
|
* -- Device and graphics adapter support 3D textures
|
|
451
424
|
* end
|
|
425
|
+
* ```
|
|
452
426
|
* @example
|
|
427
|
+
* How to create an 128x128 RGBA texture resource and assign it to a model
|
|
453
428
|
* ```ts
|
|
454
429
|
* // How to create an 128x128 RGBA texture resource and assign it to a model
|
|
455
430
|
* export default defineScript({
|
|
@@ -464,7 +439,10 @@ declare global {
|
|
|
464
439
|
* go.set("#model", "texture0", my_texture_id);
|
|
465
440
|
* },
|
|
466
441
|
* });
|
|
467
|
-
*
|
|
442
|
+
* ```
|
|
443
|
+
* @example
|
|
444
|
+
* How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object
|
|
445
|
+
* ```ts
|
|
468
446
|
* // How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object
|
|
469
447
|
* export default defineScript({
|
|
470
448
|
* init() {
|
|
@@ -498,7 +476,10 @@ declare global {
|
|
|
498
476
|
* go.set("#model", "texture0", my_texture_id);
|
|
499
477
|
* },
|
|
500
478
|
* });
|
|
501
|
-
*
|
|
479
|
+
* ```
|
|
480
|
+
* @example
|
|
481
|
+
* How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader
|
|
482
|
+
* ```ts
|
|
502
483
|
* // How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader
|
|
503
484
|
* export default defineScript({
|
|
504
485
|
* init() {
|
|
@@ -507,15 +488,18 @@ declare global {
|
|
|
507
488
|
* width: 32,
|
|
508
489
|
* height: 32,
|
|
509
490
|
* depth: 32,
|
|
510
|
-
* format:
|
|
511
|
-
* flags:
|
|
491
|
+
* format: graphics.TEXTURE_FORMAT_RGBA32F,
|
|
492
|
+
* flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,
|
|
512
493
|
* });
|
|
513
494
|
*
|
|
514
495
|
* // pass the backing texture to the render script
|
|
515
496
|
* msg.post("@render:", "add_textures", [t_volume]);
|
|
516
497
|
* },
|
|
517
498
|
* });
|
|
518
|
-
*
|
|
499
|
+
* ```
|
|
500
|
+
* @example
|
|
501
|
+
* How to create 512x512 texture array with 5 pages.
|
|
502
|
+
* ```ts
|
|
519
503
|
* // How to create 512x512 texture array with 5 pages.
|
|
520
504
|
* const new_tex = resource.create_texture("/runtime/example_array.texturec", {
|
|
521
505
|
* type: graphics.TEXTURE_TYPE_2D_ARRAY,
|
|
@@ -526,7 +510,7 @@ declare global {
|
|
|
526
510
|
* });
|
|
527
511
|
* ```
|
|
528
512
|
*/
|
|
529
|
-
function create_texture(path: string, table: { type?: number; width?: number; height?: number; depth?: number; format?: number; flags?: number; max_mipmaps?: number; compression_type?: number }, buffer?: Opaque<"buffer">): Hash;
|
|
513
|
+
function create_texture(path: string, table: { type?: number; width?: number; height?: number; depth?: number; format?: number; flags?: number; max_mipmaps?: number; compression_type?: number; page_count?: number }, buffer?: Opaque<"buffer">): Hash;
|
|
530
514
|
/**
|
|
531
515
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
532
516
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -639,14 +623,15 @@ declare global {
|
|
|
639
623
|
* @param buffer - optional buffer of precreated pixel data
|
|
640
624
|
* @param callback - callback function when texture is created (self, request_id, resource)
|
|
641
625
|
* @example
|
|
626
|
+
* Create a texture resource asyncronously with a buffer and a callback
|
|
642
627
|
* ```ts
|
|
643
628
|
* // Create a texture resource asyncronously with a buffer and a callback
|
|
644
|
-
* function callback(self, request_id,
|
|
629
|
+
* function callback(self: unknown, request_id: unknown, texture_path: unknown) {
|
|
645
630
|
* // The resource has been updated with a new texture,
|
|
646
631
|
* // so we can update other systems with the new handle,
|
|
647
632
|
* // or update components to use the resource if we want
|
|
648
|
-
* const tinfo = resource.get_texture_info(
|
|
649
|
-
* msg.post("@render:", "set_backing_texture", tinfo.handle);
|
|
633
|
+
* const tinfo = resource.get_texture_info(texture_path as Hash);
|
|
634
|
+
* msg.post("@render:", "set_backing_texture", { handle: tinfo.handle });
|
|
650
635
|
* }
|
|
651
636
|
*
|
|
652
637
|
* export default defineScript({
|
|
@@ -680,7 +665,10 @@ declare global {
|
|
|
680
665
|
* go.set("#model", "texture0", tpath);
|
|
681
666
|
* },
|
|
682
667
|
* });
|
|
683
|
-
*
|
|
668
|
+
* ```
|
|
669
|
+
* @example
|
|
670
|
+
* Create a texture resource asyncronously without a callback
|
|
671
|
+
* ```ts
|
|
684
672
|
* // Create a texture resource asyncronously without a callback
|
|
685
673
|
* export default defineScript({
|
|
686
674
|
* init() {
|
|
@@ -728,20 +716,28 @@ declare global {
|
|
|
728
716
|
* @param path - optional resource path string to the resource
|
|
729
717
|
* @returns a path hash to the binary version of the resource
|
|
730
718
|
* @example
|
|
719
|
+
* Load a font and set it to a label:
|
|
731
720
|
* ```ts
|
|
732
721
|
* // Load a font and set it to a label:
|
|
733
|
-
* go.property("my_font", resource.font("/font.font"));
|
|
734
|
-
*
|
|
735
722
|
* export default defineScript({
|
|
723
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
724
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
725
|
+
* properties: { my_font: resource.font("/font.font") },
|
|
726
|
+
*
|
|
736
727
|
* init(self) {
|
|
737
728
|
* go.set("#label", "font", self.my_font);
|
|
738
729
|
* },
|
|
739
730
|
* });
|
|
740
|
-
*
|
|
731
|
+
* ```
|
|
732
|
+
* @example
|
|
733
|
+
* Load a font and set it to a gui:
|
|
734
|
+
* ```ts
|
|
741
735
|
* // Load a font and set it to a gui:
|
|
742
|
-
* go.property("my_font", resource.font("/font.font"));
|
|
743
|
-
*
|
|
744
736
|
* export default defineScript({
|
|
737
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
738
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
739
|
+
* properties: { my_font: resource.font("/font.font") },
|
|
740
|
+
*
|
|
745
741
|
* init(self) {
|
|
746
742
|
* go.set("#gui", "fonts", self.my_font, { key: "my_font" });
|
|
747
743
|
* },
|
|
@@ -765,7 +761,7 @@ declare global {
|
|
|
765
761
|
* `geometries`, preserving the frame-to-geometry mapping used by the atlas.
|
|
766
762
|
* See resource.set_atlas for a detailed description of each field
|
|
767
763
|
*/
|
|
768
|
-
function get_atlas(path: Hash | string): { texture: string | Hash; animations: { id: string; width: number; height: number; frame_start: number; frame_end: number; playback:
|
|
764
|
+
function get_atlas(path: Hash | string): { texture: string | Hash; animations: { id: string; width: number; height: number; frame_start: number; frame_end: number; playback: go.Playback; fps: number; flip_vertical: boolean; flip_horizontal: boolean }[]; geometries: { vertices: number[]; uvs: number[]; indices: number[] }[] };
|
|
769
765
|
/**
|
|
770
766
|
* gets the buffer from a resource
|
|
771
767
|
*
|
|
@@ -776,11 +772,11 @@ declare global {
|
|
|
776
772
|
* // How to get the data from a buffer
|
|
777
773
|
* export default defineScript({
|
|
778
774
|
* init() {
|
|
779
|
-
* const res_path = go.get("#mesh", "vertices");
|
|
775
|
+
* const res_path = go.get<mesh.properties>()("#mesh", "vertices");
|
|
780
776
|
* const buf = resource.get_buffer(res_path);
|
|
781
777
|
* const stream_positions = buffer.get_stream(buf, "position");
|
|
782
778
|
*
|
|
783
|
-
* for (let i = 0; i < stream_positions.length; i++) {
|
|
779
|
+
* for (let i = 0; i < stream_positions.length(); i++) {
|
|
784
780
|
* print(i, stream_positions[i]);
|
|
785
781
|
* }
|
|
786
782
|
* },
|
|
@@ -828,14 +824,12 @@ declare global {
|
|
|
828
824
|
*
|
|
829
825
|
* - `resource.BUFFER_TYPE_DEPTH`
|
|
830
826
|
*
|
|
831
|
-
* -
|
|
832
|
-
* `resource.BUFFER_TYPE_STENCIL`
|
|
833
|
-
*
|
|
834
|
-
* -
|
|
827
|
+
* - `resource.BUFFER_TYPE_STENCIL`
|
|
835
828
|
*
|
|
836
|
-
* `texture`
|
|
829
|
+
* - `texture`
|
|
837
830
|
* hash The hashed path to the attachment texture resource. This field is only available if the render target passed in is a resource.
|
|
838
831
|
* @example
|
|
832
|
+
* Get the metadata from a render target resource
|
|
839
833
|
* ```ts
|
|
840
834
|
* // Get the metadata from a render target resource
|
|
841
835
|
* export default defineScript({
|
|
@@ -847,7 +841,10 @@ declare global {
|
|
|
847
841
|
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);
|
|
848
842
|
* },
|
|
849
843
|
* });
|
|
850
|
-
*
|
|
844
|
+
* ```
|
|
845
|
+
* @example
|
|
846
|
+
* Get a texture attachment from a render target and set it on a model component
|
|
847
|
+
* ```ts
|
|
851
848
|
* // Get a texture attachment from a render target and set it on a model component
|
|
852
849
|
* export default defineScript({
|
|
853
850
|
* init() {
|
|
@@ -889,7 +886,7 @@ declare global {
|
|
|
889
886
|
* ```ts
|
|
890
887
|
* export default defineScript({
|
|
891
888
|
* init() {
|
|
892
|
-
* const font = go.get("#label", "font");
|
|
889
|
+
* const font = go.get<label.properties>()("#label", "font");
|
|
893
890
|
* const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
|
|
894
891
|
* pprint(metrics);
|
|
895
892
|
* },
|
|
@@ -932,6 +929,7 @@ declare global {
|
|
|
932
929
|
*
|
|
933
930
|
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
934
931
|
* @example
|
|
932
|
+
* Create a new texture and get the metadata from it
|
|
935
933
|
* ```ts
|
|
936
934
|
* // Create a new texture and get the metadata from it
|
|
937
935
|
* export default defineScript({
|
|
@@ -960,7 +958,10 @@ declare global {
|
|
|
960
958
|
* // }
|
|
961
959
|
* },
|
|
962
960
|
* });
|
|
963
|
-
*
|
|
961
|
+
* ```
|
|
962
|
+
* @example
|
|
963
|
+
* Get the meta data from an atlas resource
|
|
964
|
+
* ```ts
|
|
964
965
|
* // Get the meta data from an atlas resource
|
|
965
966
|
* export default defineScript({
|
|
966
967
|
* init() {
|
|
@@ -1004,20 +1005,28 @@ declare global {
|
|
|
1004
1005
|
* @param path - optional resource path string to the resource
|
|
1005
1006
|
* @returns a path hash to the binary version of the resource
|
|
1006
1007
|
* @example
|
|
1008
|
+
* Load a material and set it to a sprite:
|
|
1007
1009
|
* ```ts
|
|
1008
1010
|
* // Load a material and set it to a sprite:
|
|
1009
|
-
* go.property("my_material", resource.material("/material.material"));
|
|
1010
|
-
*
|
|
1011
1011
|
* export default defineScript({
|
|
1012
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1013
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1014
|
+
* properties: { my_material: resource.material("/material.material") },
|
|
1015
|
+
*
|
|
1012
1016
|
* init(self) {
|
|
1013
1017
|
* go.set("#sprite", "material", self.my_material);
|
|
1014
1018
|
* },
|
|
1015
1019
|
* });
|
|
1016
|
-
*
|
|
1020
|
+
* ```
|
|
1021
|
+
* @example
|
|
1022
|
+
* Load a material resource and update a named material with the resource:
|
|
1023
|
+
* ```ts
|
|
1017
1024
|
* // Load a material resource and update a named material with the resource:
|
|
1018
|
-
* go.property("my_material", resource.material("/material.material"));
|
|
1019
|
-
*
|
|
1020
1025
|
* export default defineScript({
|
|
1026
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1027
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1028
|
+
* properties: { my_material: resource.material("/material.material") },
|
|
1029
|
+
*
|
|
1021
1030
|
* init(self) {
|
|
1022
1031
|
* go.set("#gui", "materials", self.my_material, { key: "my_material" });
|
|
1023
1032
|
* },
|
|
@@ -1046,9 +1055,11 @@ declare global {
|
|
|
1046
1055
|
* @example
|
|
1047
1056
|
* ```ts
|
|
1048
1057
|
* // Set a render target color attachment as a model texture:
|
|
1049
|
-
* go.property("my_render_target", resource.render_target("/rt.render_target"));
|
|
1050
|
-
*
|
|
1051
1058
|
* export default defineScript({
|
|
1059
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1060
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1061
|
+
* properties: { my_render_target: resource.render_target("/rt.render_target") },
|
|
1062
|
+
*
|
|
1052
1063
|
* init(self) {
|
|
1053
1064
|
* const rt_info = resource.get_render_target_info(self.my_render_target);
|
|
1054
1065
|
* go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
|
|
@@ -1067,7 +1078,7 @@ declare global {
|
|
|
1067
1078
|
* // Assuming the folder "/res" is added to the project custom resources:
|
|
1068
1079
|
* // load a texture resource and set it on a sprite
|
|
1069
1080
|
* const buffer = resource.load("/res/new.texturec");
|
|
1070
|
-
* resource.set(go.get("#sprite", "texture0"), buffer);
|
|
1081
|
+
* resource.set(go.get<sprite.properties>()("#sprite", "texture0"), buffer);
|
|
1071
1082
|
* ```
|
|
1072
1083
|
*/
|
|
1073
1084
|
function set(path: string | Hash, buffer: Opaque<"buffer">): void;
|
|
@@ -1087,81 +1098,52 @@ declare global {
|
|
|
1087
1098
|
* @param path - The path to the atlas resource
|
|
1088
1099
|
* @param table - A table containing info about the atlas. Supported entries:
|
|
1089
1100
|
*
|
|
1090
|
-
* -
|
|
1091
|
-
*
|
|
1092
|
-
* `texture`
|
|
1101
|
+
* - `texture`
|
|
1093
1102
|
* string | hash the path to the texture resource, e.g "/main/my_texture.texturec"
|
|
1094
1103
|
*
|
|
1095
|
-
* -
|
|
1096
|
-
*
|
|
1097
|
-
* `animations`
|
|
1104
|
+
* - `animations`
|
|
1098
1105
|
* table a list of the animations in the atlas. Supports the following fields:
|
|
1099
1106
|
*
|
|
1100
|
-
* -
|
|
1101
|
-
*
|
|
1102
|
-
* `id`
|
|
1107
|
+
* - `id`
|
|
1103
1108
|
* string the id of the animation, used in e.g sprite.play_animation
|
|
1104
1109
|
*
|
|
1105
|
-
* -
|
|
1106
|
-
*
|
|
1107
|
-
* `width`
|
|
1110
|
+
* - `width`
|
|
1108
1111
|
* number the width of the animation
|
|
1109
1112
|
*
|
|
1110
|
-
* -
|
|
1111
|
-
*
|
|
1112
|
-
* `height`
|
|
1113
|
+
* - `height`
|
|
1113
1114
|
* number the height of the animation
|
|
1114
1115
|
*
|
|
1115
|
-
* -
|
|
1116
|
-
*
|
|
1117
|
-
* `frame_start`
|
|
1116
|
+
* - `frame_start`
|
|
1118
1117
|
* number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
|
|
1119
1118
|
*
|
|
1120
|
-
* -
|
|
1121
|
-
*
|
|
1122
|
-
* `frame_end`
|
|
1119
|
+
* - `frame_end`
|
|
1123
1120
|
* number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
|
|
1124
1121
|
*
|
|
1125
|
-
* -
|
|
1126
|
-
*
|
|
1127
|
-
* `playback`
|
|
1122
|
+
* - `playback`
|
|
1128
1123
|
* constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
|
|
1129
1124
|
*
|
|
1130
|
-
* -
|
|
1131
|
-
*
|
|
1132
|
-
* `fps`
|
|
1125
|
+
* - `fps`
|
|
1133
1126
|
* number optional fps of the animation, the default value is 30
|
|
1134
1127
|
*
|
|
1135
|
-
* -
|
|
1136
|
-
*
|
|
1137
|
-
* `flip_vertical`
|
|
1128
|
+
* - `flip_vertical`
|
|
1138
1129
|
* boolean optional flip the animation vertically, the default value is false
|
|
1139
1130
|
*
|
|
1140
|
-
* -
|
|
1141
|
-
*
|
|
1142
|
-
* `flip_horizontal`
|
|
1131
|
+
* - `flip_horizontal`
|
|
1143
1132
|
* boolean optional flip the animation horizontally, the default value is false
|
|
1144
1133
|
*
|
|
1145
|
-
* -
|
|
1146
|
-
*
|
|
1147
|
-
* `geometries`
|
|
1134
|
+
* - `geometries`
|
|
1148
1135
|
* table A list of the geometries that should map to the texture data. Supports the following fields:
|
|
1149
1136
|
*
|
|
1150
|
-
* -
|
|
1151
|
-
*
|
|
1152
|
-
* `vertices`
|
|
1137
|
+
* - `vertices`
|
|
1153
1138
|
* table a list of the vertices in texture space of the geometry in the form {px0, py0, px1, py1, ..., pxn, pyn}
|
|
1154
1139
|
*
|
|
1155
|
-
* -
|
|
1156
|
-
*
|
|
1157
|
-
* `uvs`
|
|
1140
|
+
* - `uvs`
|
|
1158
1141
|
* table a list of the uv coordinates in texture space of the geometry in the form of {u0, v0, u1, v1, ..., un, vn}
|
|
1159
1142
|
*
|
|
1160
|
-
* -
|
|
1161
|
-
*
|
|
1162
|
-
* `indices`
|
|
1143
|
+
* - `indices`
|
|
1163
1144
|
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
1164
1145
|
* @example
|
|
1146
|
+
* Add a new animation to an existing atlas
|
|
1165
1147
|
* ```ts
|
|
1166
1148
|
* // Add a new animation to an existing atlas
|
|
1167
1149
|
* export default defineScript({
|
|
@@ -1175,12 +1157,17 @@ declare global {
|
|
|
1175
1157
|
* frame_end: 6,
|
|
1176
1158
|
* playback: go.PLAYBACK_LOOP_PINGPONG,
|
|
1177
1159
|
* fps: 8,
|
|
1160
|
+
* flip_vertical: false,
|
|
1161
|
+
* flip_horizontal: false,
|
|
1178
1162
|
* };
|
|
1179
1163
|
* data.animations.push(my_animation);
|
|
1180
1164
|
* resource.set_atlas("/main/my_atlas.a.texturesetc", data);
|
|
1181
1165
|
* },
|
|
1182
1166
|
* });
|
|
1183
|
-
*
|
|
1167
|
+
* ```
|
|
1168
|
+
* @example
|
|
1169
|
+
* Sets atlas data for a 256x256 texture with a single animation being rendered as a quad
|
|
1170
|
+
* ```ts
|
|
1184
1171
|
* // Sets atlas data for a 256x256 texture with a single animation being rendered as a quad
|
|
1185
1172
|
* export default defineScript({
|
|
1186
1173
|
* init() {
|
|
@@ -1207,7 +1194,7 @@ declare global {
|
|
|
1207
1194
|
* });
|
|
1208
1195
|
* ```
|
|
1209
1196
|
*/
|
|
1210
|
-
function set_atlas(path: Hash | string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?:
|
|
1197
|
+
function set_atlas(path: Hash | string, table: { texture?: string | Hash; animations?: { id?: string; width?: number; height?: number; frame_start?: number; frame_end?: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean }[]; geometries?: { vertices?: number[]; uvs?: number[]; indices?: number[] }[]; vertices?: number[]; uvs?: number[]; indices?: number[] }): void;
|
|
1211
1198
|
/**
|
|
1212
1199
|
* Sets the buffer of a resource. By default, setting the resource buffer will either copy the data from the incoming buffer object
|
|
1213
1200
|
* to the buffer stored in the destination resource, or make a new buffer object if the sizes between the source buffer and the destination buffer
|
|
@@ -1221,22 +1208,20 @@ declare global {
|
|
|
1221
1208
|
* @param buffer - The resource buffer
|
|
1222
1209
|
* @param table - A table containing info about how to set the buffer. Supported entries:
|
|
1223
1210
|
*
|
|
1224
|
-
* -
|
|
1225
|
-
*
|
|
1226
|
-
* `transfer_ownership`
|
|
1211
|
+
* - `transfer_ownership`
|
|
1227
1212
|
* boolean optional flag to determine whether or not the resource should take over ownership of the buffer object (default false)
|
|
1228
1213
|
* @example
|
|
1229
1214
|
* ```ts
|
|
1230
1215
|
* // How to set the data from a buffer
|
|
1231
|
-
* function fill_stream(stream, verts) {
|
|
1216
|
+
* function fill_stream(stream: { [index: number]: number }, verts: number[]) {
|
|
1232
1217
|
* verts.forEach((value, key) => {
|
|
1233
|
-
* stream[key] =
|
|
1218
|
+
* stream[key] = value;
|
|
1234
1219
|
* });
|
|
1235
1220
|
* }
|
|
1236
1221
|
*
|
|
1237
1222
|
* export default defineScript({
|
|
1238
1223
|
* init() {
|
|
1239
|
-
* const res_path = go.get("#mesh", "vertices");
|
|
1224
|
+
* const res_path = go.get<mesh.properties>()("#mesh", "vertices");
|
|
1240
1225
|
*
|
|
1241
1226
|
* const positions = [
|
|
1242
1227
|
* 1, -1, 0,
|
|
@@ -1350,62 +1335,74 @@ declare global {
|
|
|
1350
1335
|
* if graphics.TEXTURE_TYPE_3D ~= nil then
|
|
1351
1336
|
* -- Device and graphics adapter support 3D textures
|
|
1352
1337
|
* end
|
|
1338
|
+
* ```
|
|
1353
1339
|
* @example
|
|
1340
|
+
* How to set all pixels of an atlas
|
|
1354
1341
|
* ```ts
|
|
1355
1342
|
* // How to set all pixels of an atlas
|
|
1356
1343
|
* export default defineScript({
|
|
1357
|
-
* init(
|
|
1358
|
-
*
|
|
1359
|
-
*
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1363
|
-
* for (let y = 0; y <
|
|
1364
|
-
* for (let x = 0; x <
|
|
1365
|
-
* const index = y *
|
|
1366
|
-
*
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1344
|
+
* init() {
|
|
1345
|
+
* const height = 128;
|
|
1346
|
+
* const width = 128;
|
|
1347
|
+
* const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
1348
|
+
* const stream = buffer.get_stream(buf, hash("rgb"));
|
|
1349
|
+
*
|
|
1350
|
+
* for (let y = 0; y < height; y++) {
|
|
1351
|
+
* for (let x = 0; x < width; x++) {
|
|
1352
|
+
* const index = y * width * 3 + x * 3;
|
|
1353
|
+
* stream[index + 0] = 0xff;
|
|
1354
|
+
* stream[index + 1] = 0x80;
|
|
1355
|
+
* stream[index + 2] = 0x10;
|
|
1369
1356
|
* }
|
|
1370
1357
|
* }
|
|
1371
1358
|
*
|
|
1372
|
-
* const resource_path = go.get("#model", "texture0");
|
|
1373
|
-
* const args = { width
|
|
1374
|
-
* resource.set_texture(resource_path, args,
|
|
1359
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1360
|
+
* const args = { width, height, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };
|
|
1361
|
+
* resource.set_texture(resource_path, args, buf);
|
|
1362
|
+
* return { buffer: buf, stream };
|
|
1375
1363
|
* },
|
|
1376
1364
|
* });
|
|
1377
|
-
*
|
|
1365
|
+
* ```
|
|
1366
|
+
* @example
|
|
1367
|
+
* How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.
|
|
1368
|
+
* ```ts
|
|
1378
1369
|
* // How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.
|
|
1379
1370
|
* export default defineScript({
|
|
1380
|
-
* init(
|
|
1381
|
-
*
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1388
|
-
* for (let
|
|
1389
|
-
* for (let
|
|
1390
|
-
* const index =
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1371
|
+
* init() {
|
|
1372
|
+
* const x = 16;
|
|
1373
|
+
* const y = 16;
|
|
1374
|
+
* const height = 128 - x * 2;
|
|
1375
|
+
* const width = 128 - y * 2;
|
|
1376
|
+
* const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
1377
|
+
* const stream = buffer.get_stream(buf, hash("rgb"));
|
|
1378
|
+
*
|
|
1379
|
+
* for (let row = 0; row < height; row++) {
|
|
1380
|
+
* for (let col = 0; col < width; col++) {
|
|
1381
|
+
* const index = row * width * 3 + col * 3;
|
|
1382
|
+
* stream[index + 0] = 0xff;
|
|
1383
|
+
* stream[index + 1] = 0x80;
|
|
1384
|
+
* stream[index + 2] = 0x10;
|
|
1394
1385
|
* }
|
|
1395
1386
|
* }
|
|
1396
1387
|
*
|
|
1397
|
-
* const resource_path = go.get("#model", "texture0");
|
|
1398
|
-
* const args = { width
|
|
1399
|
-
* resource.set_texture(resource_path, args,
|
|
1388
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1389
|
+
* const args = { width, height, x, y, type: graphics.TEXTURE_TYPE_2D, format: graphics.TEXTURE_FORMAT_RGB, num_mip_maps: 1 };
|
|
1390
|
+
* resource.set_texture(resource_path, args, buf);
|
|
1391
|
+
* return { buffer: buf, stream };
|
|
1400
1392
|
* },
|
|
1401
1393
|
* });
|
|
1402
|
-
*
|
|
1394
|
+
* ```
|
|
1395
|
+
* @example
|
|
1396
|
+
* Update a texture from a buffer resource
|
|
1397
|
+
* ```ts
|
|
1403
1398
|
* // Update a texture from a buffer resource
|
|
1404
|
-
* go.property("my_buffer", resource.buffer("/my_default_buffer.buffer"));
|
|
1405
|
-
*
|
|
1406
1399
|
* export default defineScript({
|
|
1400
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1401
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1402
|
+
* properties: { my_buffer: resource.buffer("/my_default_buffer.buffer") },
|
|
1403
|
+
*
|
|
1407
1404
|
* init(self) {
|
|
1408
|
-
* const resource_path = go.get("#model", "texture0");
|
|
1405
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1409
1406
|
* // the "my_buffer" resource is expected to hold 128 * 128 * 3 bytes!
|
|
1410
1407
|
* const args = {
|
|
1411
1408
|
* width: 128,
|
|
@@ -1419,7 +1416,10 @@ declare global {
|
|
|
1419
1416
|
* resource.set_texture(resource_path, args, resource.get_buffer(self.my_buffer));
|
|
1420
1417
|
* },
|
|
1421
1418
|
* });
|
|
1422
|
-
*
|
|
1419
|
+
* ```
|
|
1420
|
+
* @example
|
|
1421
|
+
* Update an existing 3D texture from a lua buffer
|
|
1422
|
+
* ```ts
|
|
1423
1423
|
* // Update an existing 3D texture from a buffer
|
|
1424
1424
|
* export default defineScript({
|
|
1425
1425
|
* init() {
|
|
@@ -1446,7 +1446,7 @@ declare global {
|
|
|
1446
1446
|
* width: 8,
|
|
1447
1447
|
* height: 8,
|
|
1448
1448
|
* depth: 8,
|
|
1449
|
-
* format:
|
|
1449
|
+
* format: graphics.TEXTURE_FORMAT_RGBA32F,
|
|
1450
1450
|
* };
|
|
1451
1451
|
*
|
|
1452
1452
|
* // This expects that the texture resource "/my_3d_texture.texturec" already exists
|
|
@@ -1455,24 +1455,37 @@ declare global {
|
|
|
1455
1455
|
* resource.set_texture("/my_3d_texture.texturec", t_args, tbuffer);
|
|
1456
1456
|
* },
|
|
1457
1457
|
* });
|
|
1458
|
-
*
|
|
1458
|
+
* ```
|
|
1459
|
+
* @example
|
|
1460
|
+
* ```ts
|
|
1459
1461
|
* // Update texture 2nd array page with loaded texture from png
|
|
1460
|
-
* // new_tex is resource handle of texture which was created via resource.create_resource
|
|
1461
1462
|
* const tex_path = "/bundle_resources/page_02.png";
|
|
1462
1463
|
* const [data] = sys.load_resource(tex_path);
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1464
|
+
* if (data !== undefined) {
|
|
1465
|
+
* const buf = image.load_buffer(data);
|
|
1466
|
+
* if (buf !== undefined) {
|
|
1467
|
+
* // new_tex is the resource handle of a texture created via resource.create_texture
|
|
1468
|
+
* const new_tex = resource.create_texture("/my_array_texture.texturec", {
|
|
1469
|
+
* type: graphics.TEXTURE_TYPE_2D_ARRAY,
|
|
1470
|
+
* width: buf.width,
|
|
1471
|
+
* height: buf.height,
|
|
1472
|
+
* page_count: 2,
|
|
1473
|
+
* format: graphics.TEXTURE_FORMAT_RGB,
|
|
1474
|
+
* });
|
|
1475
|
+
* resource.set_texture(
|
|
1476
|
+
* new_tex,
|
|
1477
|
+
* {
|
|
1478
|
+
* type: graphics.TEXTURE_TYPE_2D_ARRAY,
|
|
1479
|
+
* width: buf.width,
|
|
1480
|
+
* height: buf.height,
|
|
1481
|
+
* page: 1,
|
|
1482
|
+
* format: graphics.TEXTURE_FORMAT_RGB,
|
|
1483
|
+
* },
|
|
1484
|
+
* buf.buffer,
|
|
1485
|
+
* );
|
|
1486
|
+
* go.set("#mesh", "texture0", new_tex);
|
|
1487
|
+
* }
|
|
1488
|
+
* }
|
|
1476
1489
|
* ```
|
|
1477
1490
|
*/
|
|
1478
1491
|
function set_texture(path: Hash | string, table: { type?: number; width?: number; height?: number; format?: number; x?: number; y?: number; z?: number; page?: number; mipmap?: number; compression_type?: number }, buffer: Opaque<"buffer">): void;
|
|
@@ -1490,9 +1503,11 @@ declare global {
|
|
|
1490
1503
|
* @example
|
|
1491
1504
|
* ```ts
|
|
1492
1505
|
* // Load a texture and set it to a model:
|
|
1493
|
-
* go.property("my_texture", resource.texture("/texture.png"));
|
|
1494
|
-
*
|
|
1495
1506
|
* export default defineScript({
|
|
1507
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1508
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1509
|
+
* properties: { my_texture: resource.texture("/texture.png") },
|
|
1510
|
+
*
|
|
1496
1511
|
* init(self) {
|
|
1497
1512
|
* go.set("#model", "texture0", self.my_texture);
|
|
1498
1513
|
* },
|
|
@@ -1514,9 +1529,11 @@ declare global {
|
|
|
1514
1529
|
* @example
|
|
1515
1530
|
* ```ts
|
|
1516
1531
|
* // Load tile source and set it to a tile map:
|
|
1517
|
-
* go.property("my_tile_source", resource.tile_source("/tilesource.tilesource"));
|
|
1518
|
-
*
|
|
1519
1532
|
* export default defineScript({
|
|
1533
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1534
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1535
|
+
* properties: { my_tile_source: resource.tile_source("/tilesource.tilesource") },
|
|
1536
|
+
*
|
|
1520
1537
|
* init(self) {
|
|
1521
1538
|
* go.set("#tilemap", "tile_source", self.my_tile_source);
|
|
1522
1539
|
* },
|