@defold-typescript/types 0.39.0 → 0.41.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 +4024 -716
- package/api-migrations.json +27 -0
- package/api-signatures.json +18118 -10264
- package/api-targets.json +448 -11
- package/examples/translations.json +619 -148
- package/fixtures/messages_doc.json +96 -0
- package/generated/b2d.d.ts +680 -4
- package/generated/b2d_body.d.ts +29 -103
- package/generated/b2d_chain.d.ts +5 -6
- package/generated/b2d_fixture.d.ts +34 -38
- package/generated/b2d_joint.d.ts +503 -25
- package/generated/b2d_shape.d.ts +199 -14
- package/generated/b2d_world.d.ts +57 -63
- package/generated/buffer.d.ts +33 -29
- package/generated/builtin-messages.d.ts +7 -1
- package/generated/bullet3d.d.ts +91 -0
- package/generated/bullet3d_collision_object.d.ts +433 -0
- package/generated/bullet3d_constraint.d.ts +818 -0
- package/generated/bullet3d_rigid_body.d.ts +429 -0
- package/generated/bullet3d_shape.d.ts +123 -0
- package/generated/bullet3d_world.d.ts +492 -0
- package/generated/camera.d.ts +31 -34
- package/generated/collectionfactory.d.ts +26 -27
- package/generated/collectionproxy.d.ts +22 -6
- package/generated/compute.d.ts +12 -238
- package/generated/crash.d.ts +24 -10
- package/generated/editor-vm/http.d.ts +90 -7
- package/generated/editor-vm/image.d.ts +7 -7
- package/generated/editor-vm/json.d.ts +11 -0
- package/generated/editor-vm/localization.d.ts +7 -7
- package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
- package/generated/editor-vm/zip.d.ts +28 -0
- package/generated/editor.d.ts +1496 -430
- package/generated/factory.d.ts +21 -25
- package/generated/font.d.ts +64 -22
- package/generated/go.d.ts +243 -186
- package/generated/graphics.d.ts +374 -84
- package/generated/gui.d.ts +282 -492
- package/generated/html5.d.ts +5 -3
- package/generated/http.d.ts +31 -36
- package/generated/image.d.ts +127 -85
- package/generated/json.d.ts +34 -16
- package/generated/kinds/gui-script.d.ts +8 -0
- package/generated/kinds/render-script.d.ts +8 -0
- package/generated/kinds/script.d.ts +8 -0
- package/generated/label.d.ts +77 -7
- package/generated/liveupdate.d.ts +13 -10
- package/generated/material.d.ts +312 -360
- package/generated/model.d.ts +72 -42
- package/generated/particlefx.d.ts +19 -28
- package/generated/physics.d.ts +378 -144
- package/generated/profiler.d.ts +14 -24
- package/generated/render.d.ts +294 -297
- package/generated/resource.d.ts +753 -641
- package/generated/socket.d.ts +131 -134
- package/generated/sound.d.ts +65 -34
- package/generated/sprite.d.ts +39 -17
- package/generated/sys.d.ts +237 -182
- package/generated/tilemap.d.ts +21 -16
- package/generated/timer.d.ts +34 -21
- package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
- package/generated/versions/defold-1.12.4/buffer.d.ts +18 -17
- package/generated/versions/defold-1.12.4/camera.d.ts +23 -23
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +21 -19
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
- package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
- package/generated/versions/defold-1.12.4/go.d.ts +15 -17
- package/generated/versions/defold-1.12.4/gui.d.ts +111 -193
- package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
- package/generated/versions/defold-1.12.4/http.d.ts +4 -15
- package/generated/versions/defold-1.12.4/image.d.ts +38 -46
- package/generated/versions/defold-1.12.4/index.d.ts +2 -0
- package/generated/versions/defold-1.12.4/json.d.ts +10 -6
- package/generated/versions/defold-1.12.4/label.d.ts +2 -3
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
- package/generated/versions/defold-1.12.4/model.d.ts +34 -13
- package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.12.4/physics.d.ts +82 -78
- package/generated/versions/defold-1.12.4/profiler.d.ts +3 -6
- package/generated/versions/defold-1.12.4/render.d.ts +160 -132
- package/generated/versions/defold-1.12.4/resource.d.ts +212 -209
- package/generated/versions/defold-1.12.4/socket.d.ts +45 -61
- package/generated/versions/defold-1.12.4/sound.d.ts +11 -11
- package/generated/versions/defold-1.12.4/sprite.d.ts +24 -6
- package/generated/versions/defold-1.12.4/sys.d.ts +45 -68
- package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
- package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
- package/generated/versions/defold-1.12.4/vmath.d.ts +5 -26
- package/generated/versions/defold-1.12.4/window.d.ts +1 -16
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +188 -5
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
- package/generated/versions/defold-1.13.0/buffer.d.ts +18 -17
- package/generated/versions/defold-1.13.0/camera.d.ts +27 -27
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +21 -19
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.0/compute.d.ts +1 -70
- package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
- package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
- package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
- package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
- package/generated/versions/defold-1.13.0/go.d.ts +15 -17
- package/generated/versions/defold-1.13.0/graphics.d.ts +121 -37
- package/generated/versions/defold-1.13.0/gui.d.ts +111 -193
- package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
- package/generated/versions/defold-1.13.0/http.d.ts +4 -15
- package/generated/versions/defold-1.13.0/image.d.ts +38 -46
- package/generated/versions/defold-1.13.0/index.d.ts +2 -0
- package/generated/versions/defold-1.13.0/json.d.ts +10 -6
- package/generated/versions/defold-1.13.0/label.d.ts +2 -3
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
- package/generated/versions/defold-1.13.0/material.d.ts +69 -107
- package/generated/versions/defold-1.13.0/model.d.ts +34 -13
- package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.13.0/physics.d.ts +82 -78
- package/generated/versions/defold-1.13.0/profiler.d.ts +3 -6
- package/generated/versions/defold-1.13.0/render.d.ts +160 -132
- package/generated/versions/defold-1.13.0/resource.d.ts +217 -210
- package/generated/versions/defold-1.13.0/socket.d.ts +45 -61
- package/generated/versions/defold-1.13.0/sound.d.ts +11 -11
- package/generated/versions/defold-1.13.0/sprite.d.ts +24 -6
- package/generated/versions/defold-1.13.0/sys.d.ts +45 -68
- package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
- package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
- package/generated/versions/defold-1.13.0/vmath.d.ts +5 -26
- package/generated/versions/defold-1.13.0/window.d.ts +1 -16
- package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
- package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
- package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
- package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
- package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
- package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
- package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
- package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
- package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
- package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
- package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
- package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
- package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
- package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
- package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
- package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
- package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
- package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
- package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
- package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
- package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
- package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
- package/generated/versions/defold-1.13.1/font.d.ts +81 -0
- package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
- package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
- package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
- package/generated/versions/defold-1.13.1/http.d.ts +77 -0
- package/generated/versions/defold-1.13.1/image.d.ts +131 -0
- package/generated/versions/defold-1.13.1/index.d.ts +57 -0
- package/generated/versions/defold-1.13.1/json.d.ts +80 -0
- package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
- package/generated/versions/defold-1.13.1/label.d.ts +93 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
- package/generated/versions/defold-1.13.1/material.d.ts +408 -0
- package/generated/versions/defold-1.13.1/model.d.ts +272 -0
- package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
- package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
- package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
- package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
- package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
- package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
- package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
- package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
- package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
- package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
- package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
- package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
- package/generated/versions/defold-1.13.1/types.d.ts +61 -0
- package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
- package/generated/versions/defold-1.13.1/window.d.ts +183 -0
- package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
- package/generated/vmath.d.ts +6 -26
- package/generated/window.d.ts +71 -71
- package/identity-vocabulary.json +561 -0
- package/index.d.ts +8 -0
- package/package.json +13 -2
- package/scripts/example-store-io.ts +12 -1
- package/scripts/extension-goldens.ts +1 -0
- package/scripts/fidelity-baseline.json +146 -46
- package/scripts/generate-api-availability.ts +90 -12
- package/scripts/generate-api-signatures.ts +14 -3
- package/scripts/import-defold-release.ts +85 -24
- package/scripts/prose-constants.ts +157 -0
- package/scripts/regen.ts +396 -78
- package/scripts/shared-handle-methods.ts +53 -0
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/sync-api-docs.ts +16 -5
- package/src/api-availability.ts +0 -0
- package/src/api-doc.ts +201 -3
- package/src/api-identity.ts +252 -0
- package/src/component-properties.d.ts +33 -0
- package/src/core-types.ts +28 -3
- package/src/correction-pins.ts +49 -0
- package/src/custom-messages.d.ts +4 -3
- package/src/doc-comment.ts +139 -23
- package/src/doc-corrections.ts +108 -0
- package/src/editor-vm-globals.d.ts +5 -2
- package/src/emit-dts.ts +2474 -281
- package/src/emit-messages.ts +52 -0
- package/src/engine-globals.d.ts +2 -2
- package/src/example-store.ts +125 -14
- package/src/field-correction-coverage.ts +204 -0
- package/src/fnv1a.ts +16 -0
- package/src/go-overloads.d.ts +33 -13
- package/src/index-base-table.ts +145 -0
- package/src/index-slot-classifications.ts +588 -0
- package/src/index.ts +39 -2
- package/src/library-index-slot-classifications.ts +332 -0
- package/src/lifecycle.ts +61 -199
- package/src/luals-type-expr.ts +354 -0
- package/src/msg-overloads.d.ts +0 -1
- package/src/param-correction-provenance.ts +64 -0
- package/src/return-correction-provenance.ts +58 -16
- package/src/script-api.ts +3 -1
- package/src/sys-overloads.d.ts +48 -0
- package/src/vmath-overloads.d.ts +27 -1
- package/src/window-event-guard.d.ts +6 -9
- package/url-parameters.json +1 -2
|
@@ -10,7 +10,6 @@ declare global {
|
|
|
10
10
|
* Constructor-like function with two purposes:
|
|
11
11
|
*
|
|
12
12
|
* - Load the specified resource as part of loading the script
|
|
13
|
-
*
|
|
14
13
|
* - Return a hash to the run-time version of the resource
|
|
15
14
|
*
|
|
16
15
|
* This function can only be called within go.property function calls.
|
|
@@ -21,9 +20,11 @@ declare global {
|
|
|
21
20
|
* Load an atlas and set it to a sprite:
|
|
22
21
|
* ```ts
|
|
23
22
|
* // Load an atlas and set it to a sprite:
|
|
24
|
-
* go.property("my_atlas", resource.atlas("/atlas.atlas"));
|
|
25
|
-
*
|
|
26
23
|
* export default defineScript({
|
|
24
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
25
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
26
|
+
* properties: { my_atlas: resource.atlas("/atlas.atlas") },
|
|
27
|
+
*
|
|
27
28
|
* init(self) {
|
|
28
29
|
* go.set("#sprite", "image", self.my_atlas);
|
|
29
30
|
* },
|
|
@@ -33,9 +34,11 @@ declare global {
|
|
|
33
34
|
* Load an atlas and set it to a gui:
|
|
34
35
|
* ```ts
|
|
35
36
|
* // Load an atlas and set it to a gui:
|
|
36
|
-
* go.property("my_atlas", resource.atlas("/atlas.atlas"));
|
|
37
|
-
*
|
|
38
37
|
* export default defineScript({
|
|
38
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
39
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
40
|
+
* properties: { my_atlas: resource.atlas("/atlas.atlas") },
|
|
41
|
+
*
|
|
39
42
|
* init(self) {
|
|
40
43
|
* go.set("#gui", "textures", self.my_atlas, { key: "my_atlas" });
|
|
41
44
|
* },
|
|
@@ -47,7 +50,6 @@ declare global {
|
|
|
47
50
|
* Constructor-like function with two purposes:
|
|
48
51
|
*
|
|
49
52
|
* - Load the specified resource as part of loading the script
|
|
50
|
-
*
|
|
51
53
|
* - Return a hash to the run-time version of the resource
|
|
52
54
|
*
|
|
53
55
|
* This function can only be called within go.property function calls.
|
|
@@ -57,9 +59,11 @@ declare global {
|
|
|
57
59
|
* @example
|
|
58
60
|
* ```ts
|
|
59
61
|
* // Set a unique buffer it to a sprite:
|
|
60
|
-
* go.property("my_buffer", resource.buffer("/cube.buffer"));
|
|
61
|
-
*
|
|
62
62
|
* export default defineScript({
|
|
63
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
64
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
65
|
+
* properties: { my_buffer: resource.buffer("/cube.buffer") },
|
|
66
|
+
*
|
|
63
67
|
* init(self) {
|
|
64
68
|
* go.set("#mesh", "vertices", self.my_buffer);
|
|
65
69
|
* },
|
|
@@ -144,18 +148,23 @@ declare global {
|
|
|
144
148
|
*
|
|
145
149
|
* - `indices`
|
|
146
150
|
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
151
|
+
*
|
|
152
|
+
* **⚠️ `frame_start` is 1-based; passed to Defold unchanged.** **⚠️ `frame_end` is 1-based; passed to Defold unchanged.** **⚠️ `frame_start` is 1-based; passed to Defold unchanged.** **⚠️ `frame_end` is 1-based; passed to Defold unchanged.** **⚠️ `frames` is 1-based; passed to Defold unchanged.** **0️⃣ `indices` is 0-based; passed to Defold unchanged.**
|
|
147
153
|
* @returns Returns the atlas resource path
|
|
148
154
|
* @example
|
|
149
155
|
* ```ts
|
|
150
156
|
* // Create a backing texture and an atlas
|
|
151
157
|
* export default defineScript({
|
|
152
158
|
* init() {
|
|
159
|
+
* // the engine registers a texture format only when the driver supports it
|
|
160
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
161
|
+
* if (format === undefined) return;
|
|
153
162
|
* // create an empty texture
|
|
154
163
|
* const tparams = {
|
|
155
164
|
* width: 128,
|
|
156
165
|
* height: 128,
|
|
157
166
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
158
|
-
* format
|
|
167
|
+
* format,
|
|
159
168
|
* };
|
|
160
169
|
* const my_texture_id = resource.create_texture("/my_texture.texturec", tparams);
|
|
161
170
|
*
|
|
@@ -186,7 +195,7 @@ declare global {
|
|
|
186
195
|
* indices: [0, 1, 2, 0, 2, 3],
|
|
187
196
|
* },
|
|
188
197
|
* ],
|
|
189
|
-
* };
|
|
198
|
+
* } satisfies Parameters<typeof resource.create_atlas>[1];
|
|
190
199
|
* const my_atlas_id = resource.create_atlas("/my_atlas.texturesetc", aparams);
|
|
191
200
|
*
|
|
192
201
|
* // assign the atlas to the 'sprite' component on the same go
|
|
@@ -195,7 +204,7 @@ declare global {
|
|
|
195
204
|
* });
|
|
196
205
|
* ```
|
|
197
206
|
*/
|
|
198
|
-
function create_atlas(path: string, table: { texture
|
|
207
|
+
function create_atlas(path: string, table: { texture: string | Hash; animations: [{ id: string; width: number; height: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean } & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }), ...({ id: string; width: number; height: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean } & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }))[]]; geometries: [{ id?: string; width?: number; height?: number; pivot_x?: number; pivot_y?: number; rotated?: boolean; vertices: number[]; uvs: number[]; indices: number[] }, ...{ id?: string; width?: number; height?: number; pivot_x?: number; pivot_y?: number; rotated?: boolean; vertices: number[]; uvs: number[]; indices: number[] }[]]; vertices?: number[]; uvs?: number[]; indices?: number[] }): Hash;
|
|
199
208
|
/**
|
|
200
209
|
* This function creates a new buffer resource that can be used in the same way as any buffer created during build time.
|
|
201
210
|
* The function requires a valid buffer created from either buffer.create or another pre-existing buffer resource.
|
|
@@ -244,9 +253,9 @@ declare global {
|
|
|
244
253
|
* const stream = buffer.get_stream(buffer_handle, hash("position"));
|
|
245
254
|
*
|
|
246
255
|
* // transfer vertex data to buffer
|
|
247
|
-
*
|
|
248
|
-
* stream[k] =
|
|
249
|
-
* }
|
|
256
|
+
* positions.forEach((value, k) => {
|
|
257
|
+
* stream[k] = value;
|
|
258
|
+
* });
|
|
250
259
|
*
|
|
251
260
|
* const my_buffer = resource.create_buffer("/my_buffer.bufferc", { buffer: buffer_handle });
|
|
252
261
|
* go.set("/go#mesh", "vertices", my_buffer);
|
|
@@ -268,7 +277,7 @@ declare global {
|
|
|
268
277
|
* });
|
|
269
278
|
* ```
|
|
270
279
|
*/
|
|
271
|
-
function create_buffer(path: string, table
|
|
280
|
+
function create_buffer(path: string, table: { buffer: Opaque<"buffer">; transfer_ownership?: boolean }): Hash;
|
|
272
281
|
/**
|
|
273
282
|
* Creates a sound data resource
|
|
274
283
|
* Supported formats are .oggc, .opusc and .wavc
|
|
@@ -288,6 +297,11 @@ declare global {
|
|
|
288
297
|
* export default defineScript({
|
|
289
298
|
* init() {
|
|
290
299
|
* // create a new sound resource, given the initial chunk of the file
|
|
300
|
+
* const [data] = sys.load_resource("/sounds/music_header.oggc");
|
|
301
|
+
* if (data === undefined) {
|
|
302
|
+
* return;
|
|
303
|
+
* }
|
|
304
|
+
* const filesize = 1048576;
|
|
291
305
|
* const relative_path = "/a/unique/resource/name.oggc";
|
|
292
306
|
* const hash = resource.create_sound_data(relative_path, { data, filesize, partial: true });
|
|
293
307
|
* go.set("#music", "sound", hash); // override the previous sound resource
|
|
@@ -296,7 +310,7 @@ declare global {
|
|
|
296
310
|
* });
|
|
297
311
|
* ```
|
|
298
312
|
*/
|
|
299
|
-
function create_sound_data(path: string, options
|
|
313
|
+
function create_sound_data(path: string, options: { data: string | Opaque<"buffer">; filesize?: number; partial?: boolean }): Hash;
|
|
300
314
|
/**
|
|
301
315
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
302
316
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -312,13 +326,9 @@ declare global {
|
|
|
312
326
|
* number The texture type. Supported values:
|
|
313
327
|
*
|
|
314
328
|
* - `graphics.TEXTURE_TYPE_2D`
|
|
315
|
-
*
|
|
316
329
|
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
317
|
-
*
|
|
318
330
|
* - `graphics.TEXTURE_TYPE_3D`
|
|
319
|
-
*
|
|
320
331
|
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
321
|
-
*
|
|
322
332
|
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
323
333
|
*
|
|
324
334
|
* `width`
|
|
@@ -331,68 +341,46 @@ declare global {
|
|
|
331
341
|
* number The texture format, note that some of these formats might not be supported by the running device. Supported values:
|
|
332
342
|
*
|
|
333
343
|
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
334
|
-
*
|
|
335
344
|
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
336
|
-
*
|
|
337
345
|
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
338
346
|
*
|
|
339
347
|
* These constants might not be available on the device:
|
|
340
348
|
*
|
|
341
349
|
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
342
|
-
*
|
|
343
350
|
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
344
|
-
*
|
|
345
351
|
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
346
|
-
*
|
|
347
352
|
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
348
|
-
*
|
|
349
353
|
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
350
|
-
*
|
|
351
354
|
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
352
|
-
*
|
|
353
355
|
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
354
|
-
*
|
|
355
356
|
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
356
|
-
*
|
|
357
357
|
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
358
|
-
*
|
|
359
358
|
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
360
|
-
*
|
|
361
359
|
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
362
|
-
*
|
|
363
360
|
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
364
|
-
*
|
|
365
361
|
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
366
|
-
*
|
|
367
362
|
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
368
|
-
*
|
|
369
363
|
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
370
|
-
*
|
|
371
364
|
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
372
|
-
*
|
|
373
365
|
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
374
|
-
*
|
|
375
366
|
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
376
|
-
*
|
|
377
367
|
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
378
|
-
*
|
|
379
368
|
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
380
369
|
*
|
|
381
370
|
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
382
371
|
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
372
|
+
* ```ts
|
|
373
|
+
* if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
|
|
374
|
+
* // it is safe to use this format
|
|
375
|
+
* }
|
|
376
|
+
* ```
|
|
387
377
|
*
|
|
388
378
|
* `flags`
|
|
389
379
|
* number Texture creation flags that can be used to dictate how the texture is created. The default value is graphics.TEXTURE_USAGE_FLAG_SAMPLE, which means that the texture can be sampled from a shader.
|
|
390
380
|
* These flags may or may not be supported on the running device and/or the underlying graphics API and is simply used internally as a 'hint' when creating the texture. There is no guarantee that any of these will have any effect. Supported values:
|
|
391
381
|
*
|
|
392
382
|
* - `graphics.TEXTURE_USAGE_FLAG_SAMPLE` - The texture can be sampled from a shader (default)
|
|
393
|
-
*
|
|
394
383
|
* - `graphics.TEXTURE_USAGE_FLAG_MEMORYLESS` - The texture can be used as a memoryless texture, i.e only transient memory for the texture is used during rendering
|
|
395
|
-
*
|
|
396
384
|
* - `graphics.TEXTURE_USAGE_FLAG_STORAGE` - The texture can be used as a storage texture, which is required for a shader to write to the texture
|
|
397
385
|
*
|
|
398
386
|
* `max_mipmaps`
|
|
@@ -402,15 +390,14 @@ declare global {
|
|
|
402
390
|
* Creating an empty texture with no buffer data is not supported as a core feature. Defaults to graphics.COMPRESSION_TYPE_DEFAULT, i.e no compression. Supported values:
|
|
403
391
|
*
|
|
404
392
|
* - `COMPRESSION_TYPE_DEFAULT`
|
|
405
|
-
*
|
|
406
393
|
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
407
394
|
* @param buffer - optional buffer of precreated pixel data
|
|
408
395
|
* @returns The path to the resource.
|
|
409
396
|
* 3D Textures are currently only supported on OpenGL and Vulkan adapters. To check if your device supports 3D textures, use:
|
|
410
|
-
* ```
|
|
411
|
-
* if graphics.TEXTURE_TYPE_3D
|
|
412
|
-
*
|
|
413
|
-
*
|
|
397
|
+
* ```ts
|
|
398
|
+
* if (graphics.TEXTURE_TYPE_3D !== undefined) {
|
|
399
|
+
* // Device and graphics adapter support 3D textures
|
|
400
|
+
* }
|
|
414
401
|
* ```
|
|
415
402
|
* @example
|
|
416
403
|
* How to create an 128x128 RGBA texture resource and assign it to a model
|
|
@@ -418,11 +405,14 @@ declare global {
|
|
|
418
405
|
* // How to create an 128x128 RGBA texture resource and assign it to a model
|
|
419
406
|
* export default defineScript({
|
|
420
407
|
* init() {
|
|
408
|
+
* // the engine registers a texture format only when the driver supports it
|
|
409
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
410
|
+
* if (format === undefined) return;
|
|
421
411
|
* const tparams = {
|
|
422
412
|
* width: 128,
|
|
423
413
|
* height: 128,
|
|
424
414
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
425
|
-
* format
|
|
415
|
+
* format,
|
|
426
416
|
* };
|
|
427
417
|
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams);
|
|
428
418
|
* go.set("#model", "texture0", my_texture_id);
|
|
@@ -435,6 +425,9 @@ declare global {
|
|
|
435
425
|
* // How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object
|
|
436
426
|
* export default defineScript({
|
|
437
427
|
* init() {
|
|
428
|
+
* // the engine registers a texture format only when the driver supports it
|
|
429
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA32F;
|
|
430
|
+
* if (format === undefined) return;
|
|
438
431
|
* // Create a new buffer with 4 components and FLOAT32 type
|
|
439
432
|
* const tbuffer = buffer.create(128 * 128, [{ name: hash("rgba"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);
|
|
440
433
|
* const tstream = buffer.get_stream(tbuffer, hash("rgba"));
|
|
@@ -455,7 +448,7 @@ declare global {
|
|
|
455
448
|
* width: 128,
|
|
456
449
|
* height: 128,
|
|
457
450
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
458
|
-
* format
|
|
451
|
+
* format,
|
|
459
452
|
* };
|
|
460
453
|
*
|
|
461
454
|
* // Note that we pass the buffer as the last argument here!
|
|
@@ -472,13 +465,17 @@ declare global {
|
|
|
472
465
|
* // How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader
|
|
473
466
|
* export default defineScript({
|
|
474
467
|
* init() {
|
|
468
|
+
* // the engine registers a texture type or format only when the driver supports it
|
|
469
|
+
* const type = graphics.TEXTURE_TYPE_IMAGE_3D;
|
|
470
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA32F;
|
|
471
|
+
* if (type === undefined || format === undefined) return;
|
|
475
472
|
* const t_volume = resource.create_texture("/my_backing_texture.texturec", {
|
|
476
|
-
* type
|
|
473
|
+
* type,
|
|
477
474
|
* width: 32,
|
|
478
475
|
* height: 32,
|
|
479
476
|
* depth: 32,
|
|
480
|
-
* format
|
|
481
|
-
* flags:
|
|
477
|
+
* format,
|
|
478
|
+
* flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,
|
|
482
479
|
* });
|
|
483
480
|
*
|
|
484
481
|
* // pass the backing texture to the render script
|
|
@@ -490,16 +487,20 @@ declare global {
|
|
|
490
487
|
* How to create 512x512 texture array with 5 pages.
|
|
491
488
|
* ```ts
|
|
492
489
|
* // How to create 512x512 texture array with 5 pages.
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
490
|
+
* // the engine registers a texture format only when the driver supports it
|
|
491
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
492
|
+
* if (format !== undefined) {
|
|
493
|
+
* const new_tex = resource.create_texture("/runtime/example_array.texturec", {
|
|
494
|
+
* type: graphics.TEXTURE_TYPE_2D_ARRAY,
|
|
495
|
+
* width: 512,
|
|
496
|
+
* height: 512,
|
|
497
|
+
* page_count: 5,
|
|
498
|
+
* format,
|
|
499
|
+
* });
|
|
500
|
+
* }
|
|
500
501
|
* ```
|
|
501
502
|
*/
|
|
502
|
-
function create_texture(path: string, table: { type
|
|
503
|
+
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;
|
|
503
504
|
/**
|
|
504
505
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
505
506
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -518,13 +519,9 @@ declare global {
|
|
|
518
519
|
* number The texture type. Supported values:
|
|
519
520
|
*
|
|
520
521
|
* - `graphics.TEXTURE_TYPE_2D`
|
|
521
|
-
*
|
|
522
522
|
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
523
|
-
*
|
|
524
523
|
* - `graphics.TEXTURE_TYPE_3D`
|
|
525
|
-
*
|
|
526
524
|
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
527
|
-
*
|
|
528
525
|
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
529
526
|
*
|
|
530
527
|
* `width`
|
|
@@ -537,67 +534,45 @@ declare global {
|
|
|
537
534
|
* number The texture format, note that some of these formats might not be supported by the running device. Supported values:
|
|
538
535
|
*
|
|
539
536
|
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
540
|
-
*
|
|
541
537
|
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
542
|
-
*
|
|
543
538
|
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
544
539
|
*
|
|
545
540
|
* These constants might not be available on the device:
|
|
546
541
|
*
|
|
547
542
|
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
548
|
-
*
|
|
549
543
|
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
550
|
-
*
|
|
551
544
|
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
552
|
-
*
|
|
553
545
|
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
554
|
-
*
|
|
555
546
|
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
556
|
-
*
|
|
557
547
|
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
558
|
-
*
|
|
559
548
|
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
560
|
-
*
|
|
561
549
|
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
562
|
-
*
|
|
563
550
|
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
564
|
-
*
|
|
565
551
|
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
566
|
-
*
|
|
567
552
|
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
568
|
-
*
|
|
569
553
|
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
570
|
-
*
|
|
571
554
|
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
572
|
-
*
|
|
573
555
|
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
574
|
-
*
|
|
575
556
|
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
576
|
-
*
|
|
577
557
|
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
578
|
-
*
|
|
579
558
|
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
580
|
-
*
|
|
581
559
|
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
582
|
-
*
|
|
583
560
|
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
584
|
-
*
|
|
585
561
|
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
586
562
|
*
|
|
587
563
|
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
588
564
|
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
565
|
+
* ```ts
|
|
566
|
+
* if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
|
|
567
|
+
* // it is safe to use this format
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
593
570
|
*
|
|
594
571
|
* `flags`
|
|
595
572
|
* number Texture creation flags that can be used to dictate how the texture is created. Supported values:
|
|
596
573
|
*
|
|
597
574
|
* - `graphics.TEXTURE_USAGE_FLAG_SAMPLE` - The texture can be sampled from a shader (default)
|
|
598
|
-
*
|
|
599
575
|
* - `graphics.TEXTURE_USAGE_FLAG_MEMORYLESS` - The texture can be used as a memoryless texture, i.e only transient memory for the texture is used during rendering
|
|
600
|
-
*
|
|
601
576
|
* - `graphics.TEXTURE_USAGE_FLAG_STORAGE` - The texture can be used as a storage texture, which is required for a shader to write to the texture
|
|
602
577
|
*
|
|
603
578
|
* `max_mipmaps`
|
|
@@ -607,7 +582,6 @@ declare global {
|
|
|
607
582
|
* Creating an empty texture with no buffer data is not supported as a core feature. Defaults to graphics.COMPRESSION_TYPE_DEFAULT, i.e no compression. Supported values:
|
|
608
583
|
*
|
|
609
584
|
* - `COMPRESSION_TYPE_DEFAULT`
|
|
610
|
-
*
|
|
611
585
|
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
612
586
|
* @param buffer - optional buffer of precreated pixel data
|
|
613
587
|
* @param callback - callback function when texture is created (self, request_id, resource)
|
|
@@ -656,17 +630,20 @@ declare global {
|
|
|
656
630
|
* });
|
|
657
631
|
* ```
|
|
658
632
|
* @example
|
|
659
|
-
* Create a texture resource
|
|
633
|
+
* Create a texture resource asynchronously with a callback that does nothing
|
|
660
634
|
* ```ts
|
|
661
|
-
* // Create a texture resource asyncronously without
|
|
635
|
+
* // Create a texture resource asyncronously without handling its completion
|
|
662
636
|
* export default defineScript({
|
|
663
637
|
* init() {
|
|
638
|
+
* // the engine registers a texture format only when the driver supports it
|
|
639
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
640
|
+
* if (format === undefined) return;
|
|
664
641
|
* // Create a texture resource async
|
|
665
642
|
* const tparams = {
|
|
666
643
|
* width: 128,
|
|
667
644
|
* height: 128,
|
|
668
645
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
669
|
-
* format
|
|
646
|
+
* format,
|
|
670
647
|
* };
|
|
671
648
|
*
|
|
672
649
|
* // Create a new buffer with 4 components
|
|
@@ -684,7 +661,8 @@ declare global {
|
|
|
684
661
|
* }
|
|
685
662
|
* }
|
|
686
663
|
* // create the texture
|
|
687
|
-
*
|
|
664
|
+
* // the binding requires a callback function, so pass one that does nothing
|
|
665
|
+
* const [tpath, request_id] = resource.create_texture_async("/my_texture.texturec", tparams, tbuffer, () => {});
|
|
688
666
|
* // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture
|
|
689
667
|
* // that will be removed once the new texture has been updated
|
|
690
668
|
* go.set("#model", "texture0", tpath);
|
|
@@ -692,12 +670,11 @@ declare global {
|
|
|
692
670
|
* });
|
|
693
671
|
* ```
|
|
694
672
|
*/
|
|
695
|
-
function create_texture_async(path: string
|
|
673
|
+
function create_texture_async(path: string, table: { type: number; width: number; height: number; depth?: number; format: number; flags?: number; max_mipmaps?: number; compression_type?: number }, buffer: Opaque<"buffer"> | undefined, callback: (...args: unknown[]) => unknown): LuaMultiReturn<[Hash, number]>;
|
|
696
674
|
/**
|
|
697
675
|
* Constructor-like function with two purposes:
|
|
698
676
|
*
|
|
699
677
|
* - Load the specified resource as part of loading the script
|
|
700
|
-
*
|
|
701
678
|
* - Return a hash to the run-time version of the resource
|
|
702
679
|
*
|
|
703
680
|
* This function can only be called within go.property function calls.
|
|
@@ -708,9 +685,11 @@ declare global {
|
|
|
708
685
|
* Load a font and set it to a label:
|
|
709
686
|
* ```ts
|
|
710
687
|
* // Load a font and set it to a label:
|
|
711
|
-
* go.property("my_font", resource.font("/font.font"));
|
|
712
|
-
*
|
|
713
688
|
* export default defineScript({
|
|
689
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
690
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
691
|
+
* properties: { my_font: resource.font("/font.font") },
|
|
692
|
+
*
|
|
714
693
|
* init(self) {
|
|
715
694
|
* go.set("#label", "font", self.my_font);
|
|
716
695
|
* },
|
|
@@ -720,9 +699,11 @@ declare global {
|
|
|
720
699
|
* Load a font and set it to a gui:
|
|
721
700
|
* ```ts
|
|
722
701
|
* // Load a font and set it to a gui:
|
|
723
|
-
* go.property("my_font", resource.font("/font.font"));
|
|
724
|
-
*
|
|
725
702
|
* export default defineScript({
|
|
703
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
704
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
705
|
+
* properties: { my_font: resource.font("/font.font") },
|
|
706
|
+
*
|
|
726
707
|
* init(self) {
|
|
727
708
|
* go.set("#gui", "fonts", self.my_font, { key: "my_font" });
|
|
728
709
|
* },
|
|
@@ -737,16 +718,16 @@ declare global {
|
|
|
737
718
|
* @returns A table with the following entries:
|
|
738
719
|
*
|
|
739
720
|
* - texture
|
|
740
|
-
*
|
|
741
721
|
* - geometries
|
|
742
|
-
*
|
|
743
722
|
* - animations
|
|
744
723
|
*
|
|
745
724
|
* Each animation entry also contains a `frames` table with indices into
|
|
746
725
|
* `geometries`, preserving the frame-to-geometry mapping used by the atlas.
|
|
747
726
|
* See resource.set_atlas for a detailed description of each field
|
|
727
|
+
*
|
|
728
|
+
* **⚠️ `frames` is 1-based; passed to Defold unchanged.** **0️⃣ `indices` is 0-based; passed to Defold unchanged.**
|
|
748
729
|
*/
|
|
749
|
-
function get_atlas(path: Hash | string): { texture: string | Hash; animations: { id: string; width: number; height: number; frame_start: number; frame_end: number; playback:
|
|
730
|
+
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[] }[] };
|
|
750
731
|
/**
|
|
751
732
|
* gets the buffer from a resource
|
|
752
733
|
*
|
|
@@ -757,11 +738,11 @@ declare global {
|
|
|
757
738
|
* // How to get the data from a buffer
|
|
758
739
|
* export default defineScript({
|
|
759
740
|
* init() {
|
|
760
|
-
* const res_path = go.get("#mesh", "vertices");
|
|
741
|
+
* const res_path = go.get<mesh.properties>()("#mesh", "vertices");
|
|
761
742
|
* const buf = resource.get_buffer(res_path);
|
|
762
743
|
* const stream_positions = buffer.get_stream(buf, "position");
|
|
763
744
|
*
|
|
764
|
-
* for (let i = 0; i < stream_positions.length; i++) {
|
|
745
|
+
* for (let i = 0; i < stream_positions.length(); i++) {
|
|
765
746
|
* print(i, stream_positions[i]);
|
|
766
747
|
* }
|
|
767
748
|
* },
|
|
@@ -791,26 +772,18 @@ declare global {
|
|
|
791
772
|
* number The texture type. Supported values:
|
|
792
773
|
*
|
|
793
774
|
* - `graphics.TEXTURE_TYPE_2D`
|
|
794
|
-
*
|
|
795
775
|
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
796
|
-
*
|
|
797
776
|
* - `graphics.TEXTURE_TYPE_2D_ARRAY`
|
|
798
777
|
*
|
|
799
778
|
* `buffer_type`
|
|
800
779
|
* number The attachment buffer type. Supported values:
|
|
801
780
|
*
|
|
802
781
|
* - `resource.BUFFER_TYPE_COLOR0`
|
|
803
|
-
*
|
|
804
782
|
* - `resource.BUFFER_TYPE_COLOR1`
|
|
805
|
-
*
|
|
806
783
|
* - `resource.BUFFER_TYPE_COLOR2`
|
|
807
|
-
*
|
|
808
784
|
* - `resource.BUFFER_TYPE_COLOR3`
|
|
809
|
-
*
|
|
810
785
|
* - `resource.BUFFER_TYPE_DEPTH`
|
|
811
|
-
*
|
|
812
786
|
* - `resource.BUFFER_TYPE_STENCIL`
|
|
813
|
-
*
|
|
814
787
|
* - `texture`
|
|
815
788
|
* hash The hashed path to the attachment texture resource. This field is only available if the render target passed in is a resource.
|
|
816
789
|
* @example
|
|
@@ -861,24 +834,21 @@ declare global {
|
|
|
861
834
|
* @returns a table with the following fields:
|
|
862
835
|
*
|
|
863
836
|
* - width
|
|
864
|
-
*
|
|
865
837
|
* - height
|
|
866
|
-
*
|
|
867
838
|
* - max_ascent
|
|
868
|
-
*
|
|
869
839
|
* - max_descent
|
|
870
840
|
* @example
|
|
871
841
|
* ```ts
|
|
872
842
|
* export default defineScript({
|
|
873
843
|
* init() {
|
|
874
|
-
* const font = go.get("#label", "font");
|
|
844
|
+
* const font = go.get<label.properties>()("#label", "font");
|
|
875
845
|
* const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
|
|
876
846
|
* pprint(metrics);
|
|
877
847
|
* },
|
|
878
848
|
* });
|
|
879
849
|
* ```
|
|
880
850
|
*/
|
|
881
|
-
function get_text_metrics(url: Hash, text: string, options?: { width?: number; leading?: number; tracking?: number; line_break?: boolean }): { width: number; height: number; max_ascent: number; max_descent: number };
|
|
851
|
+
function get_text_metrics(url: Hash | string, text: string, options?: { width?: number; leading?: number; tracking?: number; line_break?: boolean }): { width: number; height: number; max_ascent: number; max_descent: number };
|
|
882
852
|
/**
|
|
883
853
|
* Gets texture info from a texture resource path or a texture handle
|
|
884
854
|
*
|
|
@@ -903,15 +873,10 @@ declare global {
|
|
|
903
873
|
* number The texture type. Supported values:
|
|
904
874
|
*
|
|
905
875
|
* - `graphics.TEXTURE_TYPE_2D`
|
|
906
|
-
*
|
|
907
876
|
* - `graphics.TEXTURE_TYPE_2D_ARRAY`
|
|
908
|
-
*
|
|
909
877
|
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
910
|
-
*
|
|
911
878
|
* - `graphics.TEXTURE_TYPE_3D`
|
|
912
|
-
*
|
|
913
879
|
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
914
|
-
*
|
|
915
880
|
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
916
881
|
* @example
|
|
917
882
|
* Create a new texture and get the metadata from it
|
|
@@ -919,12 +884,15 @@ declare global {
|
|
|
919
884
|
* // Create a new texture and get the metadata from it
|
|
920
885
|
* export default defineScript({
|
|
921
886
|
* init() {
|
|
887
|
+
* // the engine registers a texture format only when the driver supports it
|
|
888
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
889
|
+
* if (format === undefined) return;
|
|
922
890
|
* // create an empty texture
|
|
923
891
|
* const tparams = {
|
|
924
892
|
* width: 128,
|
|
925
893
|
* height: 128,
|
|
926
894
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
927
|
-
* format
|
|
895
|
+
* format,
|
|
928
896
|
* };
|
|
929
897
|
*
|
|
930
898
|
* const my_texture_path = resource.create_texture("/my_texture.texturec", tparams);
|
|
@@ -968,9 +936,11 @@ declare global {
|
|
|
968
936
|
* ```ts
|
|
969
937
|
* // read custom resource data into buffer
|
|
970
938
|
* const buffer = resource.load("/resources/datafile");
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
939
|
+
* ```
|
|
940
|
+
* @example
|
|
941
|
+
* In order for the engine to include custom resources in the build process, you need
|
|
942
|
+
* to specify them in the "game.project" settings file:
|
|
943
|
+
* ```ts
|
|
974
944
|
* // [project]
|
|
975
945
|
* // title = My project
|
|
976
946
|
* // version = 0.1
|
|
@@ -982,7 +952,6 @@ declare global {
|
|
|
982
952
|
* Constructor-like function with two purposes:
|
|
983
953
|
*
|
|
984
954
|
* - Load the specified resource as part of loading the script
|
|
985
|
-
*
|
|
986
955
|
* - Return a hash to the run-time version of the resource
|
|
987
956
|
*
|
|
988
957
|
* This function can only be called within go.property function calls.
|
|
@@ -993,9 +962,11 @@ declare global {
|
|
|
993
962
|
* Load a material and set it to a sprite:
|
|
994
963
|
* ```ts
|
|
995
964
|
* // Load a material and set it to a sprite:
|
|
996
|
-
* go.property("my_material", resource.material("/material.material"));
|
|
997
|
-
*
|
|
998
965
|
* export default defineScript({
|
|
966
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
967
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
968
|
+
* properties: { my_material: resource.material("/material.material") },
|
|
969
|
+
*
|
|
999
970
|
* init(self) {
|
|
1000
971
|
* go.set("#sprite", "material", self.my_material);
|
|
1001
972
|
* },
|
|
@@ -1005,9 +976,11 @@ declare global {
|
|
|
1005
976
|
* Load a material resource and update a named material with the resource:
|
|
1006
977
|
* ```ts
|
|
1007
978
|
* // Load a material resource and update a named material with the resource:
|
|
1008
|
-
* go.property("my_material", resource.material("/material.material"));
|
|
1009
|
-
*
|
|
1010
979
|
* export default defineScript({
|
|
980
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
981
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
982
|
+
* properties: { my_material: resource.material("/material.material") },
|
|
983
|
+
*
|
|
1011
984
|
* init(self) {
|
|
1012
985
|
* go.set("#gui", "materials", self.my_material, { key: "my_material" });
|
|
1013
986
|
* },
|
|
@@ -1026,7 +999,6 @@ declare global {
|
|
|
1026
999
|
* Constructor-like function with two purposes:
|
|
1027
1000
|
*
|
|
1028
1001
|
* - Load the specified resource as part of loading the script
|
|
1029
|
-
*
|
|
1030
1002
|
* - Return a hash to the run-time version of the resource
|
|
1031
1003
|
*
|
|
1032
1004
|
* This function can only be called within go.property function calls.
|
|
@@ -1036,9 +1008,11 @@ declare global {
|
|
|
1036
1008
|
* @example
|
|
1037
1009
|
* ```ts
|
|
1038
1010
|
* // Set a render target color attachment as a model texture:
|
|
1039
|
-
* go.property("my_render_target", resource.render_target("/rt.render_target"));
|
|
1040
|
-
*
|
|
1041
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_render_target: resource.render_target("/rt.render_target") },
|
|
1015
|
+
*
|
|
1042
1016
|
* init(self) {
|
|
1043
1017
|
* const rt_info = resource.get_render_target_info(self.my_render_target);
|
|
1044
1018
|
* go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
|
|
@@ -1057,7 +1031,7 @@ declare global {
|
|
|
1057
1031
|
* // Assuming the folder "/res" is added to the project custom resources:
|
|
1058
1032
|
* // load a texture resource and set it on a sprite
|
|
1059
1033
|
* const buffer = resource.load("/res/new.texturec");
|
|
1060
|
-
* resource.set(go.get("#sprite", "texture0"), buffer);
|
|
1034
|
+
* resource.set(go.get<sprite.properties>()("#sprite", "texture0"), buffer);
|
|
1061
1035
|
* ```
|
|
1062
1036
|
*/
|
|
1063
1037
|
function set(path: string | Hash, buffer: Opaque<"buffer">): void;
|
|
@@ -1121,6 +1095,8 @@ declare global {
|
|
|
1121
1095
|
*
|
|
1122
1096
|
* - `indices`
|
|
1123
1097
|
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
1098
|
+
*
|
|
1099
|
+
* **⚠️ `frame_start` is 1-based; passed to Defold unchanged.** **⚠️ `frame_end` is 1-based; passed to Defold unchanged.** **⚠️ `frame_start` is 1-based; passed to Defold unchanged.** **⚠️ `frame_end` is 1-based; passed to Defold unchanged.** **⚠️ `frames` is 1-based; passed to Defold unchanged.** **0️⃣ `indices` is 0-based; passed to Defold unchanged.**
|
|
1124
1100
|
* @example
|
|
1125
1101
|
* Add a new animation to an existing atlas
|
|
1126
1102
|
* ```ts
|
|
@@ -1136,9 +1112,25 @@ declare global {
|
|
|
1136
1112
|
* frame_end: 6,
|
|
1137
1113
|
* playback: go.PLAYBACK_LOOP_PINGPONG,
|
|
1138
1114
|
* fps: 8,
|
|
1115
|
+
* flip_vertical: false,
|
|
1116
|
+
* flip_horizontal: false,
|
|
1139
1117
|
* };
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1118
|
+
* // set_atlas takes each animation's frames as a non-empty list
|
|
1119
|
+
* const animations = data.animations.flatMap((animation) => {
|
|
1120
|
+
* // an animation described by frame_start/frame_end passes through as-is
|
|
1121
|
+
* if (!("frames" in animation)) return [animation];
|
|
1122
|
+
* const [first, ...rest] = (animation.frames as number[] | undefined) ?? [];
|
|
1123
|
+
* return first === undefined ? [] : [{ ...animation, frames: [first, ...rest] as [number, ...number[]] }];
|
|
1124
|
+
* });
|
|
1125
|
+
* // set_atlas needs at least one animation and one geometry
|
|
1126
|
+
* const [first_geometry, ...geometries] = data.geometries;
|
|
1127
|
+
* if (first_geometry !== undefined) {
|
|
1128
|
+
* resource.set_atlas("/main/my_atlas.a.texturesetc", {
|
|
1129
|
+
* ...data,
|
|
1130
|
+
* animations: [my_animation, ...animations],
|
|
1131
|
+
* geometries: [first_geometry, ...geometries],
|
|
1132
|
+
* });
|
|
1133
|
+
* }
|
|
1142
1134
|
* },
|
|
1143
1135
|
* });
|
|
1144
1136
|
* ```
|
|
@@ -1165,13 +1157,13 @@ declare global {
|
|
|
1165
1157
|
* indices: [0, 1, 2, 0, 2, 3],
|
|
1166
1158
|
* },
|
|
1167
1159
|
* ],
|
|
1168
|
-
* };
|
|
1160
|
+
* } satisfies Parameters<typeof resource.set_atlas>[1];
|
|
1169
1161
|
* resource.set_atlas("/main/test.a.texturesetc", params);
|
|
1170
1162
|
* },
|
|
1171
1163
|
* });
|
|
1172
1164
|
* ```
|
|
1173
1165
|
*/
|
|
1174
|
-
function set_atlas(path: Hash | string, table: { texture
|
|
1166
|
+
function set_atlas(path: Hash | string, table: { texture: string | Hash; animations: [{ id: string; width: number; height: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean } & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }), ...({ id: string; width: number; height: number; playback?: go.Playback; fps?: number; flip_vertical?: boolean; flip_horizontal?: boolean } & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }))[]]; geometries: [{ vertices: number[]; uvs: number[]; indices: number[] }, ...{ vertices: number[]; uvs: number[]; indices: number[] }[]]; vertices?: number[]; uvs?: number[]; indices?: number[] }): void;
|
|
1175
1167
|
/**
|
|
1176
1168
|
* Sets the buffer of a resource. By default, setting the resource buffer will either copy the data from the incoming buffer object
|
|
1177
1169
|
* 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
|
|
@@ -1198,7 +1190,7 @@ declare global {
|
|
|
1198
1190
|
*
|
|
1199
1191
|
* export default defineScript({
|
|
1200
1192
|
* init() {
|
|
1201
|
-
* const res_path = go.get("#mesh", "vertices");
|
|
1193
|
+
* const res_path = go.get<mesh.properties>()("#mesh", "vertices");
|
|
1202
1194
|
*
|
|
1203
1195
|
* const positions = [
|
|
1204
1196
|
* 1, -1, 0,
|
|
@@ -1239,13 +1231,9 @@ declare global {
|
|
|
1239
1231
|
* number The texture type. Supported values:
|
|
1240
1232
|
*
|
|
1241
1233
|
* - `graphics.TEXTURE_TYPE_2D`
|
|
1242
|
-
*
|
|
1243
1234
|
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
1244
|
-
*
|
|
1245
1235
|
* - `graphics.TEXTURE_TYPE_3D`
|
|
1246
|
-
*
|
|
1247
1236
|
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
1248
|
-
*
|
|
1249
1237
|
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
1250
1238
|
*
|
|
1251
1239
|
* `width`
|
|
@@ -1256,9 +1244,7 @@ declare global {
|
|
|
1256
1244
|
* number The texture format, note that some of these formats are platform specific. Supported values:
|
|
1257
1245
|
*
|
|
1258
1246
|
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
1259
|
-
*
|
|
1260
1247
|
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
1261
|
-
*
|
|
1262
1248
|
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
1263
1249
|
*
|
|
1264
1250
|
* These constants might not be available on the device:
|
|
@@ -1284,10 +1270,11 @@ declare global {
|
|
|
1284
1270
|
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
1285
1271
|
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
1286
1272
|
*
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1273
|
+
* ```ts
|
|
1274
|
+
* if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
|
|
1275
|
+
* // it is safe to use this format
|
|
1276
|
+
* }
|
|
1277
|
+
* ```
|
|
1291
1278
|
*
|
|
1292
1279
|
* `x`
|
|
1293
1280
|
* number optional x offset of the texture (in pixels)
|
|
@@ -1303,39 +1290,45 @@ declare global {
|
|
|
1303
1290
|
* number optional specify the compression type for the data in the buffer object that holds the texture data. Defaults to graphics.COMPRESSION_TYPE_DEFAULT, i.e no compression. Supported values:
|
|
1304
1291
|
*
|
|
1305
1292
|
* - `COMPRESSION_TYPE_DEFAULT`
|
|
1306
|
-
*
|
|
1307
1293
|
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
1294
|
+
*
|
|
1295
|
+
* **0️⃣ `page` is 0-based; passed to Defold unchanged.** **0️⃣ `mipmap` is 0-based; passed to Defold unchanged.**
|
|
1308
1296
|
* @param buffer - The buffer of precreated pixel data
|
|
1309
1297
|
* To update a cube map texture you need to pass in six times the amount of data via the buffer, since a cube map has six sides!
|
|
1310
1298
|
* 3D Textures are currently only supported on OpenGL and Vulkan adapters. To check if your device supports 3D textures, use:
|
|
1311
|
-
* ```
|
|
1312
|
-
* if graphics.TEXTURE_TYPE_3D
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1299
|
+
* ```ts
|
|
1300
|
+
* if (graphics.TEXTURE_TYPE_3D !== undefined) {
|
|
1301
|
+
* // Device and graphics adapter support 3D textures
|
|
1302
|
+
* }
|
|
1315
1303
|
* ```
|
|
1316
1304
|
* @example
|
|
1317
1305
|
* How to set all pixels of an atlas
|
|
1318
1306
|
* ```ts
|
|
1319
1307
|
* // How to set all pixels of an atlas
|
|
1320
1308
|
* export default defineScript({
|
|
1321
|
-
* init(
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
* for (let y = 0; y <
|
|
1328
|
-
* for (let x = 0; x <
|
|
1329
|
-
* const index = y *
|
|
1330
|
-
*
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1309
|
+
* init() {
|
|
1310
|
+
* const height = 128;
|
|
1311
|
+
* const width = 128;
|
|
1312
|
+
* const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
1313
|
+
* const stream = buffer.get_stream(buf, hash("rgb"));
|
|
1314
|
+
*
|
|
1315
|
+
* for (let y = 0; y < height; y++) {
|
|
1316
|
+
* for (let x = 0; x < width; x++) {
|
|
1317
|
+
* const index = y * width * 3 + x * 3;
|
|
1318
|
+
* stream[index + 0] = 0xff;
|
|
1319
|
+
* stream[index + 1] = 0x80;
|
|
1320
|
+
* stream[index + 2] = 0x10;
|
|
1333
1321
|
* }
|
|
1334
1322
|
* }
|
|
1335
1323
|
*
|
|
1336
|
-
*
|
|
1337
|
-
* const
|
|
1338
|
-
*
|
|
1324
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1325
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1326
|
+
* if (format !== undefined) {
|
|
1327
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1328
|
+
* const args = { width, height, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };
|
|
1329
|
+
* resource.set_texture(resource_path, args, buf);
|
|
1330
|
+
* }
|
|
1331
|
+
* return { buffer: buf, stream };
|
|
1339
1332
|
* },
|
|
1340
1333
|
* });
|
|
1341
1334
|
* ```
|
|
@@ -1344,26 +1337,31 @@ declare global {
|
|
|
1344
1337
|
* ```ts
|
|
1345
1338
|
* // How to update a specific region of an atlas by using the x,y values. Assumes the already set atlas is a 128x128 texture.
|
|
1346
1339
|
* export default defineScript({
|
|
1347
|
-
* init(
|
|
1348
|
-
*
|
|
1349
|
-
*
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
* for (let
|
|
1356
|
-
* for (let
|
|
1357
|
-
* const index =
|
|
1358
|
-
*
|
|
1359
|
-
*
|
|
1360
|
-
*
|
|
1340
|
+
* init() {
|
|
1341
|
+
* const x = 16;
|
|
1342
|
+
* const y = 16;
|
|
1343
|
+
* const height = 128 - x * 2;
|
|
1344
|
+
* const width = 128 - y * 2;
|
|
1345
|
+
* const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
1346
|
+
* const stream = buffer.get_stream(buf, hash("rgb"));
|
|
1347
|
+
*
|
|
1348
|
+
* for (let row = 0; row < height; row++) {
|
|
1349
|
+
* for (let col = 0; col < width; col++) {
|
|
1350
|
+
* const index = row * width * 3 + col * 3;
|
|
1351
|
+
* stream[index + 0] = 0xff;
|
|
1352
|
+
* stream[index + 1] = 0x80;
|
|
1353
|
+
* stream[index + 2] = 0x10;
|
|
1361
1354
|
* }
|
|
1362
1355
|
* }
|
|
1363
1356
|
*
|
|
1364
|
-
*
|
|
1365
|
-
* const
|
|
1366
|
-
*
|
|
1357
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1358
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1359
|
+
* if (format !== undefined) {
|
|
1360
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1361
|
+
* const args = { width, height, x, y, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };
|
|
1362
|
+
* resource.set_texture(resource_path, args, buf);
|
|
1363
|
+
* }
|
|
1364
|
+
* return { buffer: buf, stream };
|
|
1367
1365
|
* },
|
|
1368
1366
|
* });
|
|
1369
1367
|
* ```
|
|
@@ -1371,17 +1369,22 @@ declare global {
|
|
|
1371
1369
|
* Update a texture from a buffer resource
|
|
1372
1370
|
* ```ts
|
|
1373
1371
|
* // Update a texture from a buffer resource
|
|
1374
|
-
* go.property("my_buffer", resource.buffer("/my_default_buffer.buffer"));
|
|
1375
|
-
*
|
|
1376
1372
|
* export default defineScript({
|
|
1373
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1374
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1375
|
+
* properties: { my_buffer: resource.buffer("/my_default_buffer.buffer") },
|
|
1376
|
+
*
|
|
1377
1377
|
* init(self) {
|
|
1378
|
-
*
|
|
1378
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1379
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1380
|
+
* if (format === undefined) return;
|
|
1381
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1379
1382
|
* // the "my_buffer" resource is expected to hold 128 * 128 * 3 bytes!
|
|
1380
1383
|
* const args = {
|
|
1381
1384
|
* width: 128,
|
|
1382
1385
|
* height: 128,
|
|
1383
1386
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
1384
|
-
* format
|
|
1387
|
+
* format,
|
|
1385
1388
|
* };
|
|
1386
1389
|
* // Note that the extra resource.get_buffer call is a requirement here
|
|
1387
1390
|
* // since the "self.my_buffer" is just pointing to a buffer resource path
|
|
@@ -1419,7 +1422,7 @@ declare global {
|
|
|
1419
1422
|
* width: 8,
|
|
1420
1423
|
* height: 8,
|
|
1421
1424
|
* depth: 8,
|
|
1422
|
-
* format:
|
|
1425
|
+
* format: graphics.TEXTURE_FORMAT_RGBA32F,
|
|
1423
1426
|
* };
|
|
1424
1427
|
*
|
|
1425
1428
|
* // This expects that the texture resource "/my_3d_texture.texturec" already exists
|
|
@@ -1434,7 +1437,9 @@ declare global {
|
|
|
1434
1437
|
* // Update texture 2nd array page with loaded texture from png
|
|
1435
1438
|
* const tex_path = "/bundle_resources/page_02.png";
|
|
1436
1439
|
* const [data] = sys.load_resource(tex_path);
|
|
1437
|
-
*
|
|
1440
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1441
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1442
|
+
* if (data !== undefined && format !== undefined) {
|
|
1438
1443
|
* const buf = image.load_buffer(data);
|
|
1439
1444
|
* if (buf !== undefined) {
|
|
1440
1445
|
* // new_tex is the resource handle of a texture created via resource.create_texture
|
|
@@ -1443,7 +1448,7 @@ declare global {
|
|
|
1443
1448
|
* width: buf.width,
|
|
1444
1449
|
* height: buf.height,
|
|
1445
1450
|
* page_count: 2,
|
|
1446
|
-
* format
|
|
1451
|
+
* format,
|
|
1447
1452
|
* });
|
|
1448
1453
|
* resource.set_texture(
|
|
1449
1454
|
* new_tex,
|
|
@@ -1452,7 +1457,7 @@ declare global {
|
|
|
1452
1457
|
* width: buf.width,
|
|
1453
1458
|
* height: buf.height,
|
|
1454
1459
|
* page: 1,
|
|
1455
|
-
* format
|
|
1460
|
+
* format,
|
|
1456
1461
|
* },
|
|
1457
1462
|
* buf.buffer,
|
|
1458
1463
|
* );
|
|
@@ -1461,12 +1466,11 @@ declare global {
|
|
|
1461
1466
|
* }
|
|
1462
1467
|
* ```
|
|
1463
1468
|
*/
|
|
1464
|
-
function set_texture(path: Hash | string, table: { type
|
|
1469
|
+
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;
|
|
1465
1470
|
/**
|
|
1466
1471
|
* Constructor-like function with two purposes:
|
|
1467
1472
|
*
|
|
1468
1473
|
* - Load the specified resource as part of loading the script
|
|
1469
|
-
*
|
|
1470
1474
|
* - Return a hash to the run-time version of the resource
|
|
1471
1475
|
*
|
|
1472
1476
|
* This function can only be called within go.property function calls.
|
|
@@ -1476,9 +1480,11 @@ declare global {
|
|
|
1476
1480
|
* @example
|
|
1477
1481
|
* ```ts
|
|
1478
1482
|
* // Load a texture and set it to a model:
|
|
1479
|
-
* go.property("my_texture", resource.texture("/texture.png"));
|
|
1480
|
-
*
|
|
1481
1483
|
* export default defineScript({
|
|
1484
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1485
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1486
|
+
* properties: { my_texture: resource.texture("/texture.png") },
|
|
1487
|
+
*
|
|
1482
1488
|
* init(self) {
|
|
1483
1489
|
* go.set("#model", "texture0", self.my_texture);
|
|
1484
1490
|
* },
|
|
@@ -1490,7 +1496,6 @@ declare global {
|
|
|
1490
1496
|
* Constructor-like function with two purposes:
|
|
1491
1497
|
*
|
|
1492
1498
|
* - Load the specified resource as part of loading the script
|
|
1493
|
-
*
|
|
1494
1499
|
* - Return a hash to the run-time version of the resource
|
|
1495
1500
|
*
|
|
1496
1501
|
* This function can only be called within go.property function calls.
|
|
@@ -1500,9 +1505,11 @@ declare global {
|
|
|
1500
1505
|
* @example
|
|
1501
1506
|
* ```ts
|
|
1502
1507
|
* // Load tile source and set it to a tile map:
|
|
1503
|
-
* go.property("my_tile_source", resource.tile_source("/tilesource.tilesource"));
|
|
1504
|
-
*
|
|
1505
1508
|
* export default defineScript({
|
|
1509
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1510
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1511
|
+
* properties: { my_tile_source: resource.tile_source("/tilesource.tilesource") },
|
|
1512
|
+
*
|
|
1506
1513
|
* init(self) {
|
|
1507
1514
|
* go.set("#tilemap", "tile_source", self.my_tile_source);
|
|
1508
1515
|
* },
|