@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
package/generated/resource.d.ts
CHANGED
|
@@ -6,24 +6,501 @@ declare global {
|
|
|
6
6
|
* Functions and constants to access resources.
|
|
7
7
|
*/
|
|
8
8
|
namespace resource {
|
|
9
|
+
/**
|
|
10
|
+
* Animation data accepted when creating or updating an atlas. Specify either
|
|
11
|
+
* `frames`, or both `frame_start` and `frame_end`.
|
|
12
|
+
*/
|
|
13
|
+
interface animation {
|
|
14
|
+
/**
|
|
15
|
+
* Animation id.
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Animation width.
|
|
20
|
+
*/
|
|
21
|
+
width: number;
|
|
22
|
+
/**
|
|
23
|
+
* Animation height.
|
|
24
|
+
*/
|
|
25
|
+
height: number;
|
|
26
|
+
/**
|
|
27
|
+
* Geometry indices for the animation frames.
|
|
28
|
+
*/
|
|
29
|
+
frames?: number[];
|
|
30
|
+
/**
|
|
31
|
+
* First geometry index for the legacy contiguous frame range.
|
|
32
|
+
*/
|
|
33
|
+
frame_start?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Non-inclusive last geometry index for the legacy contiguous frame range.
|
|
36
|
+
*/
|
|
37
|
+
frame_end?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Playback mode. The default is `go.PLAYBACK_ONCE_FORWARD`.
|
|
40
|
+
*/
|
|
41
|
+
playback?: go.PLAYBACK;
|
|
42
|
+
/**
|
|
43
|
+
* Animation frame rate. The default is 30.
|
|
44
|
+
*/
|
|
45
|
+
fps?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to flip the animation vertically. The default is false.
|
|
48
|
+
*/
|
|
49
|
+
flip_vertical?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to flip the animation horizontally. The default is false.
|
|
52
|
+
*/
|
|
53
|
+
flip_horizontal?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Animation data returned by resource.get_atlas.
|
|
57
|
+
*/
|
|
58
|
+
interface animation_data {
|
|
59
|
+
/**
|
|
60
|
+
* Animation id.
|
|
61
|
+
*/
|
|
62
|
+
id: string;
|
|
63
|
+
/**
|
|
64
|
+
* Animation width.
|
|
65
|
+
*/
|
|
66
|
+
width: number;
|
|
67
|
+
/**
|
|
68
|
+
* Animation height.
|
|
69
|
+
*/
|
|
70
|
+
height: number;
|
|
71
|
+
/**
|
|
72
|
+
* Geometry indices for the animation frames.
|
|
73
|
+
*/
|
|
74
|
+
frames: number[];
|
|
75
|
+
/**
|
|
76
|
+
* Playback mode.
|
|
77
|
+
*/
|
|
78
|
+
playback: go.PLAYBACK;
|
|
79
|
+
/**
|
|
80
|
+
* Animation frame rate.
|
|
81
|
+
*/
|
|
82
|
+
fps: number;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the animation is flipped vertically.
|
|
85
|
+
*/
|
|
86
|
+
flip_vertical: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether the animation is flipped horizontally.
|
|
89
|
+
*/
|
|
90
|
+
flip_horizontal: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Data accepted by resource.create_atlas and resource.set_atlas.
|
|
94
|
+
*/
|
|
95
|
+
interface atlas {
|
|
96
|
+
/**
|
|
97
|
+
* Path to the texture resource, for example `"/main/my_texture.texturec"`.
|
|
98
|
+
*/
|
|
99
|
+
texture: string | Hash;
|
|
100
|
+
/**
|
|
101
|
+
* Animations in the atlas.
|
|
102
|
+
*/
|
|
103
|
+
animations: [Omit<resource.animation, "frame_start" | "frame_end"> & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }), ...(Omit<resource.animation, "frame_start" | "frame_end"> & ({ frames: [number, ...number[]] } | { frame_start: number; frame_end: number }))[]];
|
|
104
|
+
/**
|
|
105
|
+
* Geometries that map to the texture data.
|
|
106
|
+
*/
|
|
107
|
+
geometries: [resource.geometry, ...resource.geometry[]];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Data returned by resource.get_atlas.
|
|
111
|
+
*/
|
|
112
|
+
interface atlas_data {
|
|
113
|
+
/**
|
|
114
|
+
* Path to the texture resource.
|
|
115
|
+
*/
|
|
116
|
+
texture: string | Hash;
|
|
117
|
+
/**
|
|
118
|
+
* Animations in the atlas.
|
|
119
|
+
*/
|
|
120
|
+
animations: resource.animation_data[];
|
|
121
|
+
/**
|
|
122
|
+
* Geometries that map to the texture data.
|
|
123
|
+
*/
|
|
124
|
+
geometries: resource.geometry_data[];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Buffer-resource creation parameters
|
|
128
|
+
*/
|
|
129
|
+
interface buffer_creation_params {
|
|
130
|
+
/**
|
|
131
|
+
* Buffer to bind to the resource.
|
|
132
|
+
*/
|
|
133
|
+
buffer: Opaque<"buffer">;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the resource takes ownership of the buffer. The default is true.
|
|
136
|
+
*/
|
|
137
|
+
transfer_ownership?: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Buffer-resource update options
|
|
141
|
+
*/
|
|
142
|
+
interface buffer_update_options {
|
|
143
|
+
/**
|
|
144
|
+
* Whether the resource takes ownership of the buffer. The default is false.
|
|
145
|
+
*/
|
|
146
|
+
transfer_ownership?: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Geometry data accepted when creating or updating an atlas. Vertex, UV, and
|
|
150
|
+
* index values are zero-based.
|
|
151
|
+
*/
|
|
152
|
+
interface geometry {
|
|
153
|
+
/**
|
|
154
|
+
* Geometry name, used when matching animations between atlases.
|
|
155
|
+
*/
|
|
156
|
+
id?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Width of the image represented by the geometry. If omitted, it is calculated from the vertices.
|
|
159
|
+
*/
|
|
160
|
+
width?: number;
|
|
161
|
+
/**
|
|
162
|
+
* Height of the image represented by the geometry. If omitted, it is calculated from the vertices.
|
|
163
|
+
*/
|
|
164
|
+
height?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Horizontal pivot in unit coordinates. The default is 0.5.
|
|
167
|
+
*/
|
|
168
|
+
pivot_x?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Vertical pivot in unit coordinates. The default is 0.5.
|
|
171
|
+
*/
|
|
172
|
+
pivot_y?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Whether the image is rotated 90 degrees counter-clockwise in the atlas.
|
|
175
|
+
*/
|
|
176
|
+
rotated?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Vertex coordinates in image space as `{px0, py0, px1, py1, ...}`.
|
|
179
|
+
*/
|
|
180
|
+
vertices: number[];
|
|
181
|
+
/**
|
|
182
|
+
* UV coordinates in image space as `{u0, v0, u1, v1, ...}`.
|
|
183
|
+
*/
|
|
184
|
+
uvs: number[];
|
|
185
|
+
/**
|
|
186
|
+
* Geometry indices where each group of three entries represents a triangle.
|
|
187
|
+
*/
|
|
188
|
+
indices: number[];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Geometry data returned by resource.get_atlas.
|
|
192
|
+
*/
|
|
193
|
+
interface geometry_data {
|
|
194
|
+
/**
|
|
195
|
+
* Width of the image represented by the geometry.
|
|
196
|
+
*/
|
|
197
|
+
width: number;
|
|
198
|
+
/**
|
|
199
|
+
* Height of the image represented by the geometry.
|
|
200
|
+
*/
|
|
201
|
+
height: number;
|
|
202
|
+
/**
|
|
203
|
+
* Horizontal pivot in unit coordinates.
|
|
204
|
+
*/
|
|
205
|
+
pivot_x: number;
|
|
206
|
+
/**
|
|
207
|
+
* Vertical pivot in unit coordinates.
|
|
208
|
+
*/
|
|
209
|
+
pivot_y: number;
|
|
210
|
+
/**
|
|
211
|
+
* Whether the image is rotated 90 degrees counter-clockwise in the atlas.
|
|
212
|
+
*/
|
|
213
|
+
rotated: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Vertex coordinates in image space as `{px0, py0, px1, py1, ...}`.
|
|
216
|
+
*/
|
|
217
|
+
vertices: number[];
|
|
218
|
+
/**
|
|
219
|
+
* UV coordinates in image space as `{u0, v0, u1, v1, ...}`.
|
|
220
|
+
*/
|
|
221
|
+
uvs: number[];
|
|
222
|
+
/**
|
|
223
|
+
* Geometry indices where each group of three entries represents a triangle.
|
|
224
|
+
*/
|
|
225
|
+
indices: number[];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Render target attachment information
|
|
229
|
+
*/
|
|
230
|
+
interface render_target_attachment_info {
|
|
231
|
+
/**
|
|
232
|
+
* Opaque texture handle.
|
|
233
|
+
*/
|
|
234
|
+
handle: Opaque<"texture">;
|
|
235
|
+
/**
|
|
236
|
+
* Texture width.
|
|
237
|
+
*/
|
|
238
|
+
width: number;
|
|
239
|
+
/**
|
|
240
|
+
* Texture height.
|
|
241
|
+
*/
|
|
242
|
+
height: number;
|
|
243
|
+
/**
|
|
244
|
+
* Texture depth or layer count.
|
|
245
|
+
*/
|
|
246
|
+
depth: number;
|
|
247
|
+
/**
|
|
248
|
+
* Texture page count.
|
|
249
|
+
*/
|
|
250
|
+
page_count: number;
|
|
251
|
+
/**
|
|
252
|
+
* Number of mipmaps.
|
|
253
|
+
*/
|
|
254
|
+
mipmaps: number;
|
|
255
|
+
/**
|
|
256
|
+
* Texture usage flags.
|
|
257
|
+
*/
|
|
258
|
+
flags: graphics.TEXTURE_USAGE_FLAG | number;
|
|
259
|
+
/**
|
|
260
|
+
* Texture type.
|
|
261
|
+
*/
|
|
262
|
+
type: graphics.TEXTURE_TYPE;
|
|
263
|
+
/**
|
|
264
|
+
* Render-target buffer type.
|
|
265
|
+
*/
|
|
266
|
+
buffer_type: graphics.BUFFER_TYPE;
|
|
267
|
+
/**
|
|
268
|
+
* Backing texture resource, when present.
|
|
269
|
+
*/
|
|
270
|
+
texture?: Hash;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Render target information
|
|
274
|
+
*/
|
|
275
|
+
interface render_target_info {
|
|
276
|
+
/**
|
|
277
|
+
* Opaque render-target handle.
|
|
278
|
+
*/
|
|
279
|
+
handle: Opaque<"render_target">;
|
|
280
|
+
/**
|
|
281
|
+
* Effective sample count shared by all render-target attachments.
|
|
282
|
+
*/
|
|
283
|
+
sample_count: number;
|
|
284
|
+
/**
|
|
285
|
+
* Render-target attachments.
|
|
286
|
+
*/
|
|
287
|
+
attachments: resource.render_target_attachment_info[];
|
|
288
|
+
}
|
|
289
|
+
type resource_data = Hash;
|
|
290
|
+
/**
|
|
291
|
+
* Sound-data creation options
|
|
292
|
+
*/
|
|
293
|
+
interface sound_data_options {
|
|
294
|
+
/**
|
|
295
|
+
* Raw sound file data, including the file header.
|
|
296
|
+
*/
|
|
297
|
+
data: string | Opaque<"buffer">;
|
|
298
|
+
/**
|
|
299
|
+
* Complete file size when `data` is partial.
|
|
300
|
+
*/
|
|
301
|
+
filesize?: number;
|
|
302
|
+
/**
|
|
303
|
+
* Whether `data` contains only the initial file chunk.
|
|
304
|
+
*/
|
|
305
|
+
partial?: boolean;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Text metrics
|
|
309
|
+
*/
|
|
310
|
+
interface text_metrics {
|
|
311
|
+
/**
|
|
312
|
+
* Text width.
|
|
313
|
+
*/
|
|
314
|
+
width: number;
|
|
315
|
+
/**
|
|
316
|
+
* Text height.
|
|
317
|
+
*/
|
|
318
|
+
height: number;
|
|
319
|
+
/**
|
|
320
|
+
* Maximum ascent.
|
|
321
|
+
*/
|
|
322
|
+
max_ascent: number;
|
|
323
|
+
/**
|
|
324
|
+
* Maximum descent.
|
|
325
|
+
*/
|
|
326
|
+
max_descent: number;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Text metric options
|
|
330
|
+
*/
|
|
331
|
+
interface text_metrics_options {
|
|
332
|
+
/**
|
|
333
|
+
* Text-field width; unused when `line_break` is false.
|
|
334
|
+
*/
|
|
335
|
+
width?: number;
|
|
336
|
+
/**
|
|
337
|
+
* Line leading. The default is 1.
|
|
338
|
+
*/
|
|
339
|
+
leading?: number;
|
|
340
|
+
/**
|
|
341
|
+
* Character tracking. The default is 0.
|
|
342
|
+
*/
|
|
343
|
+
tracking?: number;
|
|
344
|
+
/**
|
|
345
|
+
* Whether to account for line breaks. The default is false.
|
|
346
|
+
*/
|
|
347
|
+
line_break?: boolean;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Texture creation parameters
|
|
351
|
+
*/
|
|
352
|
+
interface texture_creation_params {
|
|
353
|
+
/**
|
|
354
|
+
* Texture type.
|
|
355
|
+
*/
|
|
356
|
+
type: graphics.TEXTURE_TYPE;
|
|
357
|
+
/**
|
|
358
|
+
* Texture width in pixels; must be greater than zero.
|
|
359
|
+
*/
|
|
360
|
+
width: number;
|
|
361
|
+
/**
|
|
362
|
+
* Texture height in pixels; must be greater than zero.
|
|
363
|
+
*/
|
|
364
|
+
height: number;
|
|
365
|
+
/**
|
|
366
|
+
* Texture depth; used by 3D texture types and must be greater than zero.
|
|
367
|
+
*/
|
|
368
|
+
depth?: number;
|
|
369
|
+
/**
|
|
370
|
+
* Number of pages for a 2D array texture.
|
|
371
|
+
*/
|
|
372
|
+
page_count?: number;
|
|
373
|
+
/**
|
|
374
|
+
* Texture format. Device-specific unsupported constants evaluate to `nil`.
|
|
375
|
+
*/
|
|
376
|
+
format: graphics.TEXTURE_FORMAT;
|
|
377
|
+
/**
|
|
378
|
+
* Creation-usage hints. The default is graphics.TEXTURE_USAGE_FLAG_SAMPLE.
|
|
379
|
+
*/
|
|
380
|
+
flags?: graphics.TEXTURE_USAGE_FLAG | number;
|
|
381
|
+
/**
|
|
382
|
+
* Maximum mipmap count. The default is zero.
|
|
383
|
+
*/
|
|
384
|
+
max_mipmaps?: number;
|
|
385
|
+
/**
|
|
386
|
+
* Compression used by the supplied buffer. The default is graphics.COMPRESSION_TYPE_DEFAULT.
|
|
387
|
+
*/
|
|
388
|
+
compression_type?: graphics.COMPRESSION_TYPE;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Asynchronous texture creation result
|
|
392
|
+
*/
|
|
393
|
+
interface texture_creation_result {
|
|
394
|
+
/**
|
|
395
|
+
* Created texture resource path.
|
|
396
|
+
*/
|
|
397
|
+
path: Hash;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Texture information
|
|
401
|
+
*/
|
|
402
|
+
interface texture_info {
|
|
403
|
+
/**
|
|
404
|
+
* Opaque texture handle.
|
|
405
|
+
*/
|
|
406
|
+
handle: Opaque<"texture">;
|
|
407
|
+
/**
|
|
408
|
+
* Texture width.
|
|
409
|
+
*/
|
|
410
|
+
width: number;
|
|
411
|
+
/**
|
|
412
|
+
* Texture height.
|
|
413
|
+
*/
|
|
414
|
+
height: number;
|
|
415
|
+
/**
|
|
416
|
+
* Texture depth or layer count.
|
|
417
|
+
*/
|
|
418
|
+
depth: number;
|
|
419
|
+
/**
|
|
420
|
+
* Texture page count.
|
|
421
|
+
*/
|
|
422
|
+
page_count: number;
|
|
423
|
+
/**
|
|
424
|
+
* Number of mipmaps.
|
|
425
|
+
*/
|
|
426
|
+
mipmaps: number;
|
|
427
|
+
/**
|
|
428
|
+
* Texture usage flags.
|
|
429
|
+
*/
|
|
430
|
+
flags: graphics.TEXTURE_USAGE_FLAG | number;
|
|
431
|
+
/**
|
|
432
|
+
* Texture type.
|
|
433
|
+
*/
|
|
434
|
+
type: graphics.TEXTURE_TYPE;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Texture update parameters
|
|
438
|
+
*/
|
|
439
|
+
interface texture_update_params {
|
|
440
|
+
/**
|
|
441
|
+
* Texture type.
|
|
442
|
+
*/
|
|
443
|
+
type: graphics.TEXTURE_TYPE;
|
|
444
|
+
/**
|
|
445
|
+
* Update width in pixels.
|
|
446
|
+
*/
|
|
447
|
+
width: number;
|
|
448
|
+
/**
|
|
449
|
+
* Update height in pixels.
|
|
450
|
+
*/
|
|
451
|
+
height: number;
|
|
452
|
+
/**
|
|
453
|
+
* Update depth for a 3D texture.
|
|
454
|
+
*/
|
|
455
|
+
depth?: number;
|
|
456
|
+
/**
|
|
457
|
+
* Texture format. Device-specific unsupported constants evaluate to `nil`.
|
|
458
|
+
*/
|
|
459
|
+
format: graphics.TEXTURE_FORMAT;
|
|
460
|
+
/**
|
|
461
|
+
* X offset in pixels.
|
|
462
|
+
*/
|
|
463
|
+
x?: number;
|
|
464
|
+
/**
|
|
465
|
+
* Y offset in pixels.
|
|
466
|
+
*/
|
|
467
|
+
y?: number;
|
|
468
|
+
/**
|
|
469
|
+
* Z offset for a 3D texture.
|
|
470
|
+
*/
|
|
471
|
+
z?: number;
|
|
472
|
+
/**
|
|
473
|
+
* Zero-based page of a 2D array texture.
|
|
474
|
+
*/
|
|
475
|
+
page?: number;
|
|
476
|
+
/**
|
|
477
|
+
* Mipmap level to update.
|
|
478
|
+
*/
|
|
479
|
+
mipmap?: number;
|
|
480
|
+
/**
|
|
481
|
+
* Compression used by the supplied buffer. The default is graphics.COMPRESSION_TYPE_DEFAULT.
|
|
482
|
+
*/
|
|
483
|
+
compression_type?: graphics.COMPRESSION_TYPE;
|
|
484
|
+
}
|
|
9
485
|
/**
|
|
10
486
|
* Constructor-like function with two purposes:
|
|
11
487
|
*
|
|
12
488
|
* - Load the specified resource as part of loading the script
|
|
13
|
-
*
|
|
14
|
-
* - Return a hash to the run-time version of the resource
|
|
489
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
15
490
|
*
|
|
16
491
|
* This function can only be called within go.property function calls.
|
|
17
492
|
*
|
|
18
493
|
* @param path - optional resource path string to the resource
|
|
19
|
-
* @returns a
|
|
494
|
+
* @returns a reference to the binary version of the resource
|
|
20
495
|
* @example
|
|
21
496
|
* Load an atlas and set it to a sprite:
|
|
22
497
|
* ```ts
|
|
23
498
|
* // Load an atlas and set it to a sprite:
|
|
24
|
-
* go.property("my_atlas", resource.atlas("/atlas.atlas"));
|
|
25
|
-
*
|
|
26
499
|
* export default defineScript({
|
|
500
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
501
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
502
|
+
* properties: { my_atlas: resource.atlas("/atlas.atlas") },
|
|
503
|
+
*
|
|
27
504
|
* init(self) {
|
|
28
505
|
* go.set("#sprite", "image", self.my_atlas);
|
|
29
506
|
* },
|
|
@@ -33,9 +510,11 @@ declare global {
|
|
|
33
510
|
* Load an atlas and set it to a gui:
|
|
34
511
|
* ```ts
|
|
35
512
|
* // Load an atlas and set it to a gui:
|
|
36
|
-
* go.property("my_atlas", resource.atlas("/atlas.atlas"));
|
|
37
|
-
*
|
|
38
513
|
* export default defineScript({
|
|
514
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
515
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
516
|
+
* properties: { my_atlas: resource.atlas("/atlas.atlas") },
|
|
517
|
+
*
|
|
39
518
|
* init(self) {
|
|
40
519
|
* go.set("#gui", "textures", self.my_atlas, { key: "my_atlas" });
|
|
41
520
|
* },
|
|
@@ -47,19 +526,20 @@ declare global {
|
|
|
47
526
|
* Constructor-like function with two purposes:
|
|
48
527
|
*
|
|
49
528
|
* - Load the specified resource as part of loading the script
|
|
50
|
-
*
|
|
51
|
-
* - Return a hash to the run-time version of the resource
|
|
529
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
52
530
|
*
|
|
53
531
|
* This function can only be called within go.property function calls.
|
|
54
532
|
*
|
|
55
533
|
* @param path - optional resource path string to the resource
|
|
56
|
-
* @returns a
|
|
534
|
+
* @returns a reference to the binary version of the resource
|
|
57
535
|
* @example
|
|
58
536
|
* ```ts
|
|
59
537
|
* // Set a unique buffer it to a sprite:
|
|
60
|
-
* go.property("my_buffer", resource.buffer("/cube.buffer"));
|
|
61
|
-
*
|
|
62
538
|
* export default defineScript({
|
|
539
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
540
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
541
|
+
* properties: { my_buffer: resource.buffer("/cube.buffer") },
|
|
542
|
+
*
|
|
63
543
|
* init(self) {
|
|
64
544
|
* go.set("#mesh", "vertices", self.my_buffer);
|
|
65
545
|
* },
|
|
@@ -80,82 +560,22 @@ declare global {
|
|
|
80
560
|
* and not necessarily that it will be deleted.
|
|
81
561
|
*
|
|
82
562
|
* @param path - The path to the resource.
|
|
83
|
-
* @param table -
|
|
84
|
-
*
|
|
85
|
-
* - `texture`
|
|
86
|
-
* string | hash the path to the texture resource, e.g "/main/my_texture.texturec"
|
|
87
|
-
*
|
|
88
|
-
* - `animations`
|
|
89
|
-
* table a list of the animations in the atlas. Supports the following fields:
|
|
90
|
-
*
|
|
91
|
-
* - `id`
|
|
92
|
-
* string the id of the animation, used in e.g sprite.play_animation
|
|
93
|
-
*
|
|
94
|
-
* - `width`
|
|
95
|
-
* number the width of the animation
|
|
96
|
-
*
|
|
97
|
-
* - `height`
|
|
98
|
-
* number the height of the animation
|
|
99
|
-
*
|
|
100
|
-
* - `frame_start`
|
|
101
|
-
* number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
|
|
102
|
-
*
|
|
103
|
-
* - `frame_end`
|
|
104
|
-
* 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.
|
|
105
|
-
*
|
|
106
|
-
* - `playback`
|
|
107
|
-
* constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
|
|
108
|
-
*
|
|
109
|
-
* - `fps`
|
|
110
|
-
* number optional fps of the animation, the default value is 30
|
|
111
|
-
*
|
|
112
|
-
* - `flip_vertical`
|
|
113
|
-
* boolean optional flip the animation vertically, the default value is false
|
|
114
|
-
*
|
|
115
|
-
* - `flip_horizontal`
|
|
116
|
-
* boolean optional flip the animation horizontally, the default value is false
|
|
117
|
-
*
|
|
118
|
-
* - `geometries`
|
|
119
|
-
* table A list of the geometries that should map to the texture data. Supports the following fields:
|
|
120
|
-
*
|
|
121
|
-
* - `id`
|
|
122
|
-
* string The name of the geometry. Used when matching animations between multiple atlases
|
|
123
|
-
*
|
|
124
|
-
* - `width`
|
|
125
|
-
* number The width of the image the sprite geometry represents
|
|
126
|
-
*
|
|
127
|
-
* - `height`
|
|
128
|
-
* number The height of the image the sprite geometry represents
|
|
129
|
-
*
|
|
130
|
-
* - `pivot_x`
|
|
131
|
-
* 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.
|
|
132
|
-
*
|
|
133
|
-
* - `pivot_y`
|
|
134
|
-
* 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.
|
|
135
|
-
*
|
|
136
|
-
* - `rotated`
|
|
137
|
-
* boolean Whether the image is rotated 90 degrees counter-clockwise in the atlas. This affects UV coordinate generation for proper rendering. Default is false.
|
|
138
|
-
*
|
|
139
|
-
* - `vertices`
|
|
140
|
-
* table a list of the vertices in image space of the geometry in the form {px0, py0, px1, py1, ..., pxn, pyn}
|
|
141
|
-
*
|
|
142
|
-
* - `uvs`
|
|
143
|
-
* table a list of the uv coordinates in image space of the geometry in the form of {u0, v0, u1, v1, ..., un, vn}.
|
|
144
|
-
*
|
|
145
|
-
* - `indices`
|
|
146
|
-
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
563
|
+
* @param table - atlas creation data. **⚠️ `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
564
|
* @returns Returns the atlas resource path
|
|
148
565
|
* @example
|
|
149
566
|
* ```ts
|
|
150
567
|
* // Create a backing texture and an atlas
|
|
151
568
|
* export default defineScript({
|
|
152
569
|
* init() {
|
|
570
|
+
* // the engine registers a texture format only when the driver supports it
|
|
571
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
572
|
+
* if (format === undefined) return;
|
|
153
573
|
* // create an empty texture
|
|
154
574
|
* const tparams = {
|
|
155
575
|
* width: 128,
|
|
156
576
|
* height: 128,
|
|
157
577
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
158
|
-
* format
|
|
578
|
+
* format,
|
|
159
579
|
* };
|
|
160
580
|
* const my_texture_id = resource.create_texture("/my_texture.texturec", tparams);
|
|
161
581
|
*
|
|
@@ -186,7 +606,7 @@ declare global {
|
|
|
186
606
|
* indices: [0, 1, 2, 0, 2, 3],
|
|
187
607
|
* },
|
|
188
608
|
* ],
|
|
189
|
-
* };
|
|
609
|
+
* } satisfies Parameters<typeof resource.create_atlas>[1];
|
|
190
610
|
* const my_atlas_id = resource.create_atlas("/my_atlas.texturesetc", aparams);
|
|
191
611
|
*
|
|
192
612
|
* // assign the atlas to the 'sprite' component on the same go
|
|
@@ -195,7 +615,7 @@ declare global {
|
|
|
195
615
|
* });
|
|
196
616
|
* ```
|
|
197
617
|
*/
|
|
198
|
-
function create_atlas(path: string, table:
|
|
618
|
+
function create_atlas(path: string, table: resource.atlas): Hash;
|
|
199
619
|
/**
|
|
200
620
|
* This function creates a new buffer resource that can be used in the same way as any buffer created during build time.
|
|
201
621
|
* The function requires a valid buffer created from either buffer.create or another pre-existing buffer resource.
|
|
@@ -207,13 +627,7 @@ declare global {
|
|
|
207
627
|
* The path must also be unique, attempting to create a buffer with the same name as an existing resource will raise an error.
|
|
208
628
|
*
|
|
209
629
|
* @param path - The path to the resource.
|
|
210
|
-
* @param table -
|
|
211
|
-
*
|
|
212
|
-
* - `buffer`
|
|
213
|
-
* buffer the buffer to bind to this resource
|
|
214
|
-
*
|
|
215
|
-
* - `transfer_ownership`
|
|
216
|
-
* boolean optional flag to determine whether or not the resource should take over ownership of the buffer object (default true)
|
|
630
|
+
* @param table - buffer-resource creation parameters
|
|
217
631
|
* @returns Returns the buffer resource path
|
|
218
632
|
* @example
|
|
219
633
|
* Create a buffer object and bind it to a buffer resource
|
|
@@ -244,9 +658,9 @@ declare global {
|
|
|
244
658
|
* const stream = buffer.get_stream(buffer_handle, hash("position"));
|
|
245
659
|
*
|
|
246
660
|
* // transfer vertex data to buffer
|
|
247
|
-
*
|
|
248
|
-
* stream[k] =
|
|
249
|
-
* }
|
|
661
|
+
* positions.forEach((value, k) => {
|
|
662
|
+
* stream[k] = value;
|
|
663
|
+
* });
|
|
250
664
|
*
|
|
251
665
|
* const my_buffer = resource.create_buffer("/my_buffer.bufferc", { buffer: buffer_handle });
|
|
252
666
|
* go.set("/go#mesh", "vertices", my_buffer);
|
|
@@ -268,26 +682,24 @@ declare global {
|
|
|
268
682
|
* });
|
|
269
683
|
* ```
|
|
270
684
|
*/
|
|
271
|
-
function create_buffer(path: string, table
|
|
685
|
+
function create_buffer(path: string, table: resource.buffer_creation_params): Hash;
|
|
272
686
|
/**
|
|
273
687
|
* Creates a sound data resource
|
|
274
688
|
* Supported formats are .oggc, .opusc and .wavc
|
|
275
689
|
*
|
|
276
690
|
* @param path - the path to the resource. Must not already exist.
|
|
277
|
-
* @param options -
|
|
278
|
-
*
|
|
279
|
-
* `data`
|
|
280
|
-
* string The raw data of the file. May be partial, but must include the header of the file
|
|
281
|
-
* `filesize`
|
|
282
|
-
* number If the file is partial, it must also specify the full size of the complete file.
|
|
283
|
-
* `partial`
|
|
284
|
-
* boolean Is the data not representing the full file, but just the initial chunk?
|
|
691
|
+
* @param options - optional sound-data parameters
|
|
285
692
|
* @returns the resulting path hash to the resource
|
|
286
693
|
* @example
|
|
287
694
|
* ```ts
|
|
288
695
|
* export default defineScript({
|
|
289
696
|
* init() {
|
|
290
697
|
* // create a new sound resource, given the initial chunk of the file
|
|
698
|
+
* const [data] = sys.load_resource("/sounds/music_header.oggc");
|
|
699
|
+
* if (data === undefined) {
|
|
700
|
+
* return;
|
|
701
|
+
* }
|
|
702
|
+
* const filesize = 1048576;
|
|
291
703
|
* const relative_path = "/a/unique/resource/name.oggc";
|
|
292
704
|
* const hash = resource.create_sound_data(relative_path, { data, filesize, partial: true });
|
|
293
705
|
* go.set("#music", "sound", hash); // override the previous sound resource
|
|
@@ -296,7 +708,7 @@ declare global {
|
|
|
296
708
|
* });
|
|
297
709
|
* ```
|
|
298
710
|
*/
|
|
299
|
-
function create_sound_data(path: string, options
|
|
711
|
+
function create_sound_data(path: string, options: resource.sound_data_options): Hash;
|
|
300
712
|
/**
|
|
301
713
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
302
714
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -306,111 +718,22 @@ declare global {
|
|
|
306
718
|
* If the texture is created without a buffer, the pixel data will be blank.
|
|
307
719
|
*
|
|
308
720
|
* @param path - The path to the resource.
|
|
309
|
-
* @param table -
|
|
310
|
-
*
|
|
311
|
-
* `type`
|
|
312
|
-
* number The texture type. Supported values:
|
|
313
|
-
*
|
|
314
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
315
|
-
*
|
|
316
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
317
|
-
*
|
|
318
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
319
|
-
*
|
|
320
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
321
|
-
*
|
|
322
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
323
|
-
*
|
|
324
|
-
* `width`
|
|
325
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
326
|
-
* `height`
|
|
327
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
328
|
-
* `depth`
|
|
329
|
-
* number The depth of the texture (in pixels). Must be larger than 0. Only used when `type` is `graphics.TEXTURE_TYPE_3D` or `graphics.TEXTURE_TYPE_IMAGE_3D`.
|
|
330
|
-
* `format`
|
|
331
|
-
* number The texture format, note that some of these formats might not be supported by the running device. Supported values:
|
|
332
|
-
*
|
|
333
|
-
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
334
|
-
*
|
|
335
|
-
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
336
|
-
*
|
|
337
|
-
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
338
|
-
*
|
|
339
|
-
* These constants might not be available on the device:
|
|
340
|
-
*
|
|
341
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
342
|
-
*
|
|
343
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
344
|
-
*
|
|
345
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
346
|
-
*
|
|
347
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
348
|
-
*
|
|
349
|
-
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
350
|
-
*
|
|
351
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
352
|
-
*
|
|
353
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
354
|
-
*
|
|
355
|
-
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
356
|
-
*
|
|
357
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
358
|
-
*
|
|
359
|
-
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
360
|
-
*
|
|
361
|
-
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
362
|
-
*
|
|
363
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
364
|
-
*
|
|
365
|
-
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
366
|
-
*
|
|
367
|
-
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
368
|
-
*
|
|
369
|
-
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
370
|
-
*
|
|
371
|
-
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
372
|
-
*
|
|
373
|
-
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
374
|
-
*
|
|
375
|
-
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
376
|
-
*
|
|
377
|
-
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
378
|
-
*
|
|
379
|
-
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
380
|
-
*
|
|
381
|
-
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
382
|
-
*
|
|
383
|
-
* `if graphics.TEXTURE_FORMAT_RGBA16F ~= nil then
|
|
384
|
-
* -- it is safe to use this format
|
|
385
|
-
* end
|
|
386
|
-
* `
|
|
387
|
-
*
|
|
388
|
-
* `flags`
|
|
389
|
-
* 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
|
-
* 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
|
-
*
|
|
392
|
-
* - `graphics.TEXTURE_USAGE_FLAG_SAMPLE` - The texture can be sampled from a shader (default)
|
|
393
|
-
*
|
|
394
|
-
* - `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
|
-
* - `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
|
-
*
|
|
398
|
-
* `max_mipmaps`
|
|
399
|
-
* number optional max number of mipmaps. Defaults to zero, i.e no mipmap support
|
|
400
|
-
* `compression_type`
|
|
401
|
-
* number optional specify the compression type for the data in the buffer object that holds the texture data. Will only be used when a compressed buffer has been passed into the function.
|
|
402
|
-
* 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
|
-
*
|
|
404
|
-
* - `COMPRESSION_TYPE_DEFAULT`
|
|
405
|
-
*
|
|
406
|
-
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
721
|
+
* @param table - texture creation parameters
|
|
407
722
|
* @param buffer - optional buffer of precreated pixel data
|
|
408
723
|
* @returns The path to the resource.
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
724
|
+
* @example
|
|
725
|
+
* Check whether a texture format is supported by the device:
|
|
726
|
+
* ```ts
|
|
727
|
+
* if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
|
|
728
|
+
* // It is safe to use this format.
|
|
729
|
+
* }
|
|
730
|
+
* ```
|
|
731
|
+
* @example
|
|
732
|
+
* 3D textures are currently only supported on OpenGL and Vulkan adapters. Check whether the device supports 3D textures before using them:
|
|
733
|
+
* ```ts
|
|
734
|
+
* if (graphics.TEXTURE_TYPE_3D !== undefined) {
|
|
735
|
+
* // The device and graphics adapter support 3D textures.
|
|
736
|
+
* }
|
|
414
737
|
* ```
|
|
415
738
|
* @example
|
|
416
739
|
* How to create an 128x128 RGBA texture resource and assign it to a model
|
|
@@ -418,11 +741,14 @@ declare global {
|
|
|
418
741
|
* // How to create an 128x128 RGBA texture resource and assign it to a model
|
|
419
742
|
* export default defineScript({
|
|
420
743
|
* init() {
|
|
744
|
+
* // the engine registers a texture format only when the driver supports it
|
|
745
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
746
|
+
* if (format === undefined) return;
|
|
421
747
|
* const tparams = {
|
|
422
748
|
* width: 128,
|
|
423
749
|
* height: 128,
|
|
424
750
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
425
|
-
* format
|
|
751
|
+
* format,
|
|
426
752
|
* };
|
|
427
753
|
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams);
|
|
428
754
|
* go.set("#model", "texture0", my_texture_id);
|
|
@@ -435,6 +761,9 @@ declare global {
|
|
|
435
761
|
* // How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object
|
|
436
762
|
* export default defineScript({
|
|
437
763
|
* init() {
|
|
764
|
+
* // the engine registers a texture format only when the driver supports it
|
|
765
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA32F;
|
|
766
|
+
* if (format === undefined) return;
|
|
438
767
|
* // Create a new buffer with 4 components and FLOAT32 type
|
|
439
768
|
* const tbuffer = buffer.create(128 * 128, [{ name: hash("rgba"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);
|
|
440
769
|
* const tstream = buffer.get_stream(tbuffer, hash("rgba"));
|
|
@@ -455,7 +784,7 @@ declare global {
|
|
|
455
784
|
* width: 128,
|
|
456
785
|
* height: 128,
|
|
457
786
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
458
|
-
* format
|
|
787
|
+
* format,
|
|
459
788
|
* };
|
|
460
789
|
*
|
|
461
790
|
* // Note that we pass the buffer as the last argument here!
|
|
@@ -472,13 +801,17 @@ declare global {
|
|
|
472
801
|
* // How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader
|
|
473
802
|
* export default defineScript({
|
|
474
803
|
* init() {
|
|
804
|
+
* // the engine registers a texture type or format only when the driver supports it
|
|
805
|
+
* const type = graphics.TEXTURE_TYPE_IMAGE_3D;
|
|
806
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA32F;
|
|
807
|
+
* if (type === undefined || format === undefined) return;
|
|
475
808
|
* const t_volume = resource.create_texture("/my_backing_texture.texturec", {
|
|
476
|
-
* type
|
|
809
|
+
* type,
|
|
477
810
|
* width: 32,
|
|
478
811
|
* height: 32,
|
|
479
812
|
* depth: 32,
|
|
480
|
-
* format
|
|
481
|
-
* flags:
|
|
813
|
+
* format,
|
|
814
|
+
* flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,
|
|
482
815
|
* });
|
|
483
816
|
*
|
|
484
817
|
* // pass the backing texture to the render script
|
|
@@ -490,16 +823,20 @@ declare global {
|
|
|
490
823
|
* How to create 512x512 texture array with 5 pages.
|
|
491
824
|
* ```ts
|
|
492
825
|
* // How to create 512x512 texture array with 5 pages.
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
826
|
+
* // the engine registers a texture format only when the driver supports it
|
|
827
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
828
|
+
* if (format !== undefined) {
|
|
829
|
+
* const new_tex = resource.create_texture("/runtime/example_array.texturec", {
|
|
830
|
+
* type: graphics.TEXTURE_TYPE_2D_ARRAY,
|
|
831
|
+
* width: 512,
|
|
832
|
+
* height: 512,
|
|
833
|
+
* page_count: 5,
|
|
834
|
+
* format,
|
|
835
|
+
* });
|
|
836
|
+
* }
|
|
500
837
|
* ```
|
|
501
838
|
*/
|
|
502
|
-
function create_texture(path: string, table:
|
|
839
|
+
function create_texture(path: string, table: resource.texture_creation_params, buffer?: Opaque<"buffer">): Hash;
|
|
503
840
|
/**
|
|
504
841
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
505
842
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -513,124 +850,46 @@ declare global {
|
|
|
513
850
|
* new texture. Be careful when using the initial texture handle handle as it will not be valid after the upload has finished.
|
|
514
851
|
*
|
|
515
852
|
* @param path - The path to the resource.
|
|
516
|
-
* @param table -
|
|
517
|
-
* `type`
|
|
518
|
-
* number The texture type. Supported values:
|
|
519
|
-
*
|
|
520
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
521
|
-
*
|
|
522
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
523
|
-
*
|
|
524
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
525
|
-
*
|
|
526
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
527
|
-
*
|
|
528
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
529
|
-
*
|
|
530
|
-
* `width`
|
|
531
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
532
|
-
* `height`
|
|
533
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
534
|
-
* `depth`
|
|
535
|
-
* number The depth of the texture (in pixels). Must be larger than 0. Only used when `type` is `graphics.TEXTURE_TYPE_3D` or `graphics.TEXTURE_TYPE_IMAGE_3D`.
|
|
536
|
-
* `format`
|
|
537
|
-
* number The texture format, note that some of these formats might not be supported by the running device. Supported values:
|
|
538
|
-
*
|
|
539
|
-
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
540
|
-
*
|
|
541
|
-
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
542
|
-
*
|
|
543
|
-
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
544
|
-
*
|
|
545
|
-
* These constants might not be available on the device:
|
|
546
|
-
*
|
|
547
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
548
|
-
*
|
|
549
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
550
|
-
*
|
|
551
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
552
|
-
*
|
|
553
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
554
|
-
*
|
|
555
|
-
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
556
|
-
*
|
|
557
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
558
|
-
*
|
|
559
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
560
|
-
*
|
|
561
|
-
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
562
|
-
*
|
|
563
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
564
|
-
*
|
|
565
|
-
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
566
|
-
*
|
|
567
|
-
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
568
|
-
*
|
|
569
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
570
|
-
*
|
|
571
|
-
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
572
|
-
*
|
|
573
|
-
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
574
|
-
*
|
|
575
|
-
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
576
|
-
*
|
|
577
|
-
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
578
|
-
*
|
|
579
|
-
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
580
|
-
*
|
|
581
|
-
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
582
|
-
*
|
|
583
|
-
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
584
|
-
*
|
|
585
|
-
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
586
|
-
*
|
|
587
|
-
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
588
|
-
*
|
|
589
|
-
* `if graphics.TEXTURE_FORMAT_RGBA16F ~= nil then
|
|
590
|
-
* -- it is safe to use this format
|
|
591
|
-
* end
|
|
592
|
-
* `
|
|
593
|
-
*
|
|
594
|
-
* `flags`
|
|
595
|
-
* number Texture creation flags that can be used to dictate how the texture is created. Supported values:
|
|
596
|
-
*
|
|
597
|
-
* - `graphics.TEXTURE_USAGE_FLAG_SAMPLE` - The texture can be sampled from a shader (default)
|
|
598
|
-
*
|
|
599
|
-
* - `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
|
-
* - `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
|
-
*
|
|
603
|
-
* `max_mipmaps`
|
|
604
|
-
* number optional max number of mipmaps. Defaults to zero, i.e no mipmap support
|
|
605
|
-
* `compression_type`
|
|
606
|
-
* number optional specify the compression type for the data in the buffer object that holds the texture data. Will only be used when a compressed buffer has been passed into the function.
|
|
607
|
-
* 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
|
-
*
|
|
609
|
-
* - `COMPRESSION_TYPE_DEFAULT`
|
|
610
|
-
*
|
|
611
|
-
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
853
|
+
* @param table - texture creation parameters
|
|
612
854
|
* @param buffer - optional buffer of precreated pixel data
|
|
613
|
-
* @param callback - callback function when texture is created
|
|
855
|
+
* @param callback - callback function invoked when the texture is created
|
|
856
|
+
* @example
|
|
857
|
+
* Check whether a texture format is supported by the device:
|
|
858
|
+
* ```ts
|
|
859
|
+
* if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
|
|
860
|
+
* // It is safe to use this format.
|
|
861
|
+
* }
|
|
862
|
+
* ```
|
|
863
|
+
* @example
|
|
864
|
+
* 3D textures are currently only supported on OpenGL and Vulkan adapters. Check whether the device supports 3D textures before using them:
|
|
865
|
+
* ```ts
|
|
866
|
+
* if (graphics.TEXTURE_TYPE_3D !== undefined) {
|
|
867
|
+
* // The device and graphics adapter support 3D textures.
|
|
868
|
+
* }
|
|
869
|
+
* ```
|
|
614
870
|
* @example
|
|
615
871
|
* Create a texture resource asyncronously with a buffer and a callback
|
|
616
872
|
* ```ts
|
|
617
873
|
* // Create a texture resource asyncronously with a buffer and a callback
|
|
618
|
-
* function callback(self: unknown, request_id:
|
|
874
|
+
* function callback(self: unknown, request_id: number, result: resource.texture_creation_result) {
|
|
619
875
|
* // The resource has been updated with a new texture,
|
|
620
876
|
* // so we can update other systems with the new handle,
|
|
621
877
|
* // or update components to use the resource if we want
|
|
622
|
-
* const tinfo = resource.get_texture_info(
|
|
878
|
+
* const tinfo = resource.get_texture_info(result.path);
|
|
623
879
|
* msg.post("@render:", "set_backing_texture", { handle: tinfo.handle });
|
|
624
880
|
* }
|
|
625
881
|
*
|
|
626
882
|
* export default defineScript({
|
|
627
883
|
* init() {
|
|
884
|
+
* // the engine registers a texture format only when the driver supports it
|
|
885
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
886
|
+
* if (format === undefined) return;
|
|
628
887
|
* // Create a texture resource async
|
|
629
888
|
* const tparams = {
|
|
630
889
|
* width: 128,
|
|
631
890
|
* height: 128,
|
|
632
891
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
633
|
-
* format
|
|
892
|
+
* format,
|
|
634
893
|
* };
|
|
635
894
|
*
|
|
636
895
|
* // Create a new buffer with 4 components
|
|
@@ -656,17 +915,20 @@ declare global {
|
|
|
656
915
|
* });
|
|
657
916
|
* ```
|
|
658
917
|
* @example
|
|
659
|
-
* Create a texture resource
|
|
918
|
+
* Create a texture resource asynchronously with a callback that does nothing
|
|
660
919
|
* ```ts
|
|
661
|
-
* // Create a texture resource asyncronously without
|
|
920
|
+
* // Create a texture resource asyncronously without handling its completion
|
|
662
921
|
* export default defineScript({
|
|
663
922
|
* init() {
|
|
923
|
+
* // the engine registers a texture format only when the driver supports it
|
|
924
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
925
|
+
* if (format === undefined) return;
|
|
664
926
|
* // Create a texture resource async
|
|
665
927
|
* const tparams = {
|
|
666
928
|
* width: 128,
|
|
667
929
|
* height: 128,
|
|
668
930
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
669
|
-
* format
|
|
931
|
+
* format,
|
|
670
932
|
* };
|
|
671
933
|
*
|
|
672
934
|
* // Create a new buffer with 4 components
|
|
@@ -684,7 +946,8 @@ declare global {
|
|
|
684
946
|
* }
|
|
685
947
|
* }
|
|
686
948
|
* // create the texture
|
|
687
|
-
*
|
|
949
|
+
* // the binding requires a callback function, so pass one that does nothing
|
|
950
|
+
* const [tpath, request_id] = resource.create_texture_async("/my_texture.texturec", tparams, tbuffer, () => {});
|
|
688
951
|
* // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture
|
|
689
952
|
* // that will be removed once the new texture has been updated
|
|
690
953
|
* go.set("#model", "texture0", tpath);
|
|
@@ -692,25 +955,26 @@ declare global {
|
|
|
692
955
|
* });
|
|
693
956
|
* ```
|
|
694
957
|
*/
|
|
695
|
-
function create_texture_async(path: string
|
|
958
|
+
function create_texture_async(path: string, table: resource.texture_creation_params, buffer: Opaque<"buffer"> | undefined, callback: (self: unknown, request_id: number, result: resource.texture_creation_result) => void): LuaMultiReturn<[Hash, number]>;
|
|
696
959
|
/**
|
|
697
960
|
* Constructor-like function with two purposes:
|
|
698
961
|
*
|
|
699
962
|
* - Load the specified resource as part of loading the script
|
|
700
|
-
*
|
|
701
|
-
* - Return a hash to the run-time version of the resource
|
|
963
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
702
964
|
*
|
|
703
965
|
* This function can only be called within go.property function calls.
|
|
704
966
|
*
|
|
705
967
|
* @param path - optional resource path string to the resource
|
|
706
|
-
* @returns a
|
|
968
|
+
* @returns a reference to the binary version of the resource
|
|
707
969
|
* @example
|
|
708
970
|
* Load a font and set it to a label:
|
|
709
971
|
* ```ts
|
|
710
972
|
* // Load a font and set it to a label:
|
|
711
|
-
* go.property("my_font", resource.font("/font.font"));
|
|
712
|
-
*
|
|
713
973
|
* export default defineScript({
|
|
974
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
975
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
976
|
+
* properties: { my_font: resource.font("/font.font") },
|
|
977
|
+
*
|
|
714
978
|
* init(self) {
|
|
715
979
|
* go.set("#label", "font", self.my_font);
|
|
716
980
|
* },
|
|
@@ -720,9 +984,11 @@ declare global {
|
|
|
720
984
|
* Load a font and set it to a gui:
|
|
721
985
|
* ```ts
|
|
722
986
|
* // Load a font and set it to a gui:
|
|
723
|
-
* go.property("my_font", resource.font("/font.font"));
|
|
724
|
-
*
|
|
725
987
|
* export default defineScript({
|
|
988
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
989
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
990
|
+
* properties: { my_font: resource.font("/font.font") },
|
|
991
|
+
*
|
|
726
992
|
* init(self) {
|
|
727
993
|
* go.set("#gui", "fonts", self.my_font, { key: "my_font" });
|
|
728
994
|
* },
|
|
@@ -734,19 +1000,9 @@ declare global {
|
|
|
734
1000
|
* Returns the atlas data for an atlas
|
|
735
1001
|
*
|
|
736
1002
|
* @param path - The path to the atlas resource
|
|
737
|
-
* @returns
|
|
738
|
-
*
|
|
739
|
-
* - texture
|
|
740
|
-
*
|
|
741
|
-
* - geometries
|
|
742
|
-
*
|
|
743
|
-
* - animations
|
|
744
|
-
*
|
|
745
|
-
* Each animation entry also contains a `frames` table with indices into
|
|
746
|
-
* `geometries`, preserving the frame-to-geometry mapping used by the atlas.
|
|
747
|
-
* See resource.set_atlas for a detailed description of each field
|
|
1003
|
+
* @returns atlas data. **⚠️ `frames` is 1-based; passed to Defold unchanged.** **0️⃣ `indices` is 0-based; passed to Defold unchanged.**
|
|
748
1004
|
*/
|
|
749
|
-
function get_atlas(path: Hash | string):
|
|
1005
|
+
function get_atlas(path: Hash | string): resource.atlas_data;
|
|
750
1006
|
/**
|
|
751
1007
|
* gets the buffer from a resource
|
|
752
1008
|
*
|
|
@@ -757,11 +1013,11 @@ declare global {
|
|
|
757
1013
|
* // How to get the data from a buffer
|
|
758
1014
|
* export default defineScript({
|
|
759
1015
|
* init() {
|
|
760
|
-
* const res_path = go.get("#mesh", "vertices");
|
|
1016
|
+
* const res_path = go.get<mesh.properties>()("#mesh", "vertices");
|
|
761
1017
|
* const buf = resource.get_buffer(res_path);
|
|
762
1018
|
* const stream_positions = buffer.get_stream(buf, "position");
|
|
763
1019
|
*
|
|
764
|
-
* for (let i = 0; i < stream_positions.length; i++) {
|
|
1020
|
+
* for (let i = 0; i < stream_positions.length(); i++) {
|
|
765
1021
|
* print(i, stream_positions[i]);
|
|
766
1022
|
* }
|
|
767
1023
|
* },
|
|
@@ -773,46 +1029,7 @@ declare global {
|
|
|
773
1029
|
* Gets render target info from a render target resource path or a render target handle
|
|
774
1030
|
*
|
|
775
1031
|
* @param path - The path to the resource or a render target handle
|
|
776
|
-
* @returns
|
|
777
|
-
*
|
|
778
|
-
* `handle`
|
|
779
|
-
* number the opaque handle to the texture resource
|
|
780
|
-
* 'attachments'
|
|
781
|
-
* table a table of attachments, where each attachment contains the following entries:
|
|
782
|
-
* `width`
|
|
783
|
-
* number width of the texture
|
|
784
|
-
* `height`
|
|
785
|
-
* number height of the texture
|
|
786
|
-
* `depth`
|
|
787
|
-
* number depth of the texture (i.e 1 for a 2D texture and 6 for a cube map)
|
|
788
|
-
* `mipmaps`
|
|
789
|
-
* number number of mipmaps of the texture
|
|
790
|
-
* `type`
|
|
791
|
-
* number The texture type. Supported values:
|
|
792
|
-
*
|
|
793
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
794
|
-
*
|
|
795
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
796
|
-
*
|
|
797
|
-
* - `graphics.TEXTURE_TYPE_2D_ARRAY`
|
|
798
|
-
*
|
|
799
|
-
* `buffer_type`
|
|
800
|
-
* number The attachment buffer type. Supported values:
|
|
801
|
-
*
|
|
802
|
-
* - `resource.BUFFER_TYPE_COLOR0`
|
|
803
|
-
*
|
|
804
|
-
* - `resource.BUFFER_TYPE_COLOR1`
|
|
805
|
-
*
|
|
806
|
-
* - `resource.BUFFER_TYPE_COLOR2`
|
|
807
|
-
*
|
|
808
|
-
* - `resource.BUFFER_TYPE_COLOR3`
|
|
809
|
-
*
|
|
810
|
-
* - `resource.BUFFER_TYPE_DEPTH`
|
|
811
|
-
*
|
|
812
|
-
* - `resource.BUFFER_TYPE_STENCIL`
|
|
813
|
-
*
|
|
814
|
-
* - `texture`
|
|
815
|
-
* hash The hashed path to the attachment texture resource. This field is only available if the render target passed in is a resource.
|
|
1032
|
+
* @returns render-target information
|
|
816
1033
|
* @example
|
|
817
1034
|
* Get the metadata from a render target resource
|
|
818
1035
|
* ```ts
|
|
@@ -842,89 +1059,48 @@ declare global {
|
|
|
842
1059
|
* });
|
|
843
1060
|
* ```
|
|
844
1061
|
*/
|
|
845
|
-
function get_render_target_info(path: Hash | string |
|
|
1062
|
+
function get_render_target_info(path: Hash | string | Opaque<"render_target"> | number): resource.render_target_info;
|
|
846
1063
|
/**
|
|
847
|
-
* Gets the text metrics from a font
|
|
1064
|
+
* Gets the text metrics from a font. Rich text markup is measured using its
|
|
1065
|
+
* visible text and font sizes. If markup cannot be parsed, the text is measured literally.
|
|
1066
|
+
* Inline sprites reserve their specified dimensions, or one em by default.
|
|
848
1067
|
*
|
|
849
1068
|
* @param url - the font to get the (unscaled) metrics from
|
|
850
1069
|
* @param text - text to measure
|
|
851
|
-
* @param options -
|
|
852
|
-
*
|
|
853
|
-
* `width`
|
|
854
|
-
* number The width of the text field. Not used if `line_break` is false.
|
|
855
|
-
* `leading`
|
|
856
|
-
* number The leading (default 1.0)
|
|
857
|
-
* `tracking`
|
|
858
|
-
* number The tracking (default 0.0)
|
|
859
|
-
* `line_break`
|
|
860
|
-
* boolean If the calculation should consider line breaks (default false)
|
|
861
|
-
* @returns a table with the following fields:
|
|
862
|
-
*
|
|
863
|
-
* - width
|
|
864
|
-
*
|
|
865
|
-
* - height
|
|
866
|
-
*
|
|
867
|
-
* - max_ascent
|
|
868
|
-
*
|
|
869
|
-
* - max_descent
|
|
1070
|
+
* @param options - optional text-metric options
|
|
1071
|
+
* @returns measured text metrics
|
|
870
1072
|
* @example
|
|
871
1073
|
* ```ts
|
|
872
1074
|
* export default defineScript({
|
|
873
1075
|
* init() {
|
|
874
|
-
* const font = go.get("#label", "font");
|
|
1076
|
+
* const font = go.get<label.properties>()("#label", "font");
|
|
875
1077
|
* const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
|
|
876
1078
|
* pprint(metrics);
|
|
877
1079
|
* },
|
|
878
1080
|
* });
|
|
879
1081
|
* ```
|
|
880
1082
|
*/
|
|
881
|
-
function get_text_metrics(url: Hash, text: string, options?:
|
|
1083
|
+
function get_text_metrics(url: Hash | string, text: string, options?: resource.text_metrics_options): resource.text_metrics;
|
|
882
1084
|
/**
|
|
883
1085
|
* Gets texture info from a texture resource path or a texture handle
|
|
884
1086
|
*
|
|
885
1087
|
* @param path - The path to the resource or a texture handle
|
|
886
|
-
* @returns
|
|
887
|
-
*
|
|
888
|
-
* `handle`
|
|
889
|
-
* number the opaque handle to the texture resource
|
|
890
|
-
* `width`
|
|
891
|
-
* number width of the texture
|
|
892
|
-
* `height`
|
|
893
|
-
* number height of the texture
|
|
894
|
-
* `depth`
|
|
895
|
-
* number depth of the texture (i.e 1 for a 2D texture, 6 for a cube map, the actual depth of a 3D texture)
|
|
896
|
-
* `page_count`
|
|
897
|
-
* number number of pages of the texture array. For 2D texture value is 1. For cube map - 6
|
|
898
|
-
* `mipmaps`
|
|
899
|
-
* number number of mipmaps of the texture
|
|
900
|
-
* `flags`
|
|
901
|
-
* number usage hints of the texture.
|
|
902
|
-
* `type`
|
|
903
|
-
* number The texture type. Supported values:
|
|
904
|
-
*
|
|
905
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
906
|
-
*
|
|
907
|
-
* - `graphics.TEXTURE_TYPE_2D_ARRAY`
|
|
908
|
-
*
|
|
909
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
910
|
-
*
|
|
911
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
912
|
-
*
|
|
913
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
914
|
-
*
|
|
915
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
1088
|
+
* @returns texture information
|
|
916
1089
|
* @example
|
|
917
1090
|
* Create a new texture and get the metadata from it
|
|
918
1091
|
* ```ts
|
|
919
1092
|
* // Create a new texture and get the metadata from it
|
|
920
1093
|
* export default defineScript({
|
|
921
1094
|
* init() {
|
|
1095
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1096
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA;
|
|
1097
|
+
* if (format === undefined) return;
|
|
922
1098
|
* // create an empty texture
|
|
923
1099
|
* const tparams = {
|
|
924
1100
|
* width: 128,
|
|
925
1101
|
* height: 128,
|
|
926
1102
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
927
|
-
* format
|
|
1103
|
+
* format,
|
|
928
1104
|
* };
|
|
929
1105
|
*
|
|
930
1106
|
* const my_texture_path = resource.create_texture("/my_texture.texturec", tparams);
|
|
@@ -958,7 +1134,7 @@ declare global {
|
|
|
958
1134
|
* });
|
|
959
1135
|
* ```
|
|
960
1136
|
*/
|
|
961
|
-
function get_texture_info(path: Hash | string |
|
|
1137
|
+
function get_texture_info(path: Hash | string | Opaque<"texture"> | number): resource.texture_info;
|
|
962
1138
|
/**
|
|
963
1139
|
* Loads the resource data for a specific resource.
|
|
964
1140
|
*
|
|
@@ -968,9 +1144,11 @@ declare global {
|
|
|
968
1144
|
* ```ts
|
|
969
1145
|
* // read custom resource data into buffer
|
|
970
1146
|
* const buffer = resource.load("/resources/datafile");
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
1147
|
+
* ```
|
|
1148
|
+
* @example
|
|
1149
|
+
* In order for the engine to include custom resources in the build process, you need
|
|
1150
|
+
* to specify them in the "game.project" settings file:
|
|
1151
|
+
* ```ts
|
|
974
1152
|
* // [project]
|
|
975
1153
|
* // title = My project
|
|
976
1154
|
* // version = 0.1
|
|
@@ -982,20 +1160,21 @@ declare global {
|
|
|
982
1160
|
* Constructor-like function with two purposes:
|
|
983
1161
|
*
|
|
984
1162
|
* - Load the specified resource as part of loading the script
|
|
985
|
-
*
|
|
986
|
-
* - Return a hash to the run-time version of the resource
|
|
1163
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
987
1164
|
*
|
|
988
1165
|
* This function can only be called within go.property function calls.
|
|
989
1166
|
*
|
|
990
1167
|
* @param path - optional resource path string to the resource
|
|
991
|
-
* @returns a
|
|
1168
|
+
* @returns a reference to the binary version of the resource
|
|
992
1169
|
* @example
|
|
993
1170
|
* Load a material and set it to a sprite:
|
|
994
1171
|
* ```ts
|
|
995
1172
|
* // Load a material and set it to a sprite:
|
|
996
|
-
* go.property("my_material", resource.material("/material.material"));
|
|
997
|
-
*
|
|
998
1173
|
* export default defineScript({
|
|
1174
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1175
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1176
|
+
* properties: { my_material: resource.material("/material.material") },
|
|
1177
|
+
*
|
|
999
1178
|
* init(self) {
|
|
1000
1179
|
* go.set("#sprite", "material", self.my_material);
|
|
1001
1180
|
* },
|
|
@@ -1005,9 +1184,11 @@ declare global {
|
|
|
1005
1184
|
* Load a material resource and update a named material with the resource:
|
|
1006
1185
|
* ```ts
|
|
1007
1186
|
* // Load a material resource and update a named material with the resource:
|
|
1008
|
-
* go.property("my_material", resource.material("/material.material"));
|
|
1009
|
-
*
|
|
1010
1187
|
* export default defineScript({
|
|
1188
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1189
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1190
|
+
* properties: { my_material: resource.material("/material.material") },
|
|
1191
|
+
*
|
|
1011
1192
|
* init(self) {
|
|
1012
1193
|
* go.set("#gui", "materials", self.my_material, { key: "my_material" });
|
|
1013
1194
|
* },
|
|
@@ -1026,19 +1207,20 @@ declare global {
|
|
|
1026
1207
|
* Constructor-like function with two purposes:
|
|
1027
1208
|
*
|
|
1028
1209
|
* - Load the specified resource as part of loading the script
|
|
1029
|
-
*
|
|
1030
|
-
* - Return a hash to the run-time version of the resource
|
|
1210
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
1031
1211
|
*
|
|
1032
1212
|
* This function can only be called within go.property function calls.
|
|
1033
1213
|
*
|
|
1034
1214
|
* @param path - optional resource path string to the resource
|
|
1035
|
-
* @returns a
|
|
1215
|
+
* @returns a reference to the binary version of the resource
|
|
1036
1216
|
* @example
|
|
1037
1217
|
* ```ts
|
|
1038
1218
|
* // Set a render target color attachment as a model texture:
|
|
1039
|
-
* go.property("my_render_target", resource.render_target("/rt.render_target"));
|
|
1040
|
-
*
|
|
1041
1219
|
* export default defineScript({
|
|
1220
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1221
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1222
|
+
* properties: { my_render_target: resource.render_target("/rt.render_target") },
|
|
1223
|
+
*
|
|
1042
1224
|
* init(self) {
|
|
1043
1225
|
* const rt_info = resource.get_render_target_info(self.my_render_target);
|
|
1044
1226
|
* go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
|
|
@@ -1057,7 +1239,7 @@ declare global {
|
|
|
1057
1239
|
* // Assuming the folder "/res" is added to the project custom resources:
|
|
1058
1240
|
* // load a texture resource and set it on a sprite
|
|
1059
1241
|
* const buffer = resource.load("/res/new.texturec");
|
|
1060
|
-
* resource.set(go.get("#sprite", "texture0"), buffer);
|
|
1242
|
+
* resource.set(go.get<sprite.properties>()("#sprite", "texture0"), buffer);
|
|
1061
1243
|
* ```
|
|
1062
1244
|
*/
|
|
1063
1245
|
function set(path: string | Hash, buffer: Opaque<"buffer">): void;
|
|
@@ -1075,52 +1257,7 @@ declare global {
|
|
|
1075
1257
|
* this function.
|
|
1076
1258
|
*
|
|
1077
1259
|
* @param path - The path to the atlas resource
|
|
1078
|
-
* @param table -
|
|
1079
|
-
*
|
|
1080
|
-
* - `texture`
|
|
1081
|
-
* string | hash the path to the texture resource, e.g "/main/my_texture.texturec"
|
|
1082
|
-
*
|
|
1083
|
-
* - `animations`
|
|
1084
|
-
* table a list of the animations in the atlas. Supports the following fields:
|
|
1085
|
-
*
|
|
1086
|
-
* - `id`
|
|
1087
|
-
* string the id of the animation, used in e.g sprite.play_animation
|
|
1088
|
-
*
|
|
1089
|
-
* - `width`
|
|
1090
|
-
* number the width of the animation
|
|
1091
|
-
*
|
|
1092
|
-
* - `height`
|
|
1093
|
-
* number the height of the animation
|
|
1094
|
-
*
|
|
1095
|
-
* - `frame_start`
|
|
1096
|
-
* number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
|
|
1097
|
-
*
|
|
1098
|
-
* - `frame_end`
|
|
1099
|
-
* 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.
|
|
1100
|
-
*
|
|
1101
|
-
* - `playback`
|
|
1102
|
-
* constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
|
|
1103
|
-
*
|
|
1104
|
-
* - `fps`
|
|
1105
|
-
* number optional fps of the animation, the default value is 30
|
|
1106
|
-
*
|
|
1107
|
-
* - `flip_vertical`
|
|
1108
|
-
* boolean optional flip the animation vertically, the default value is false
|
|
1109
|
-
*
|
|
1110
|
-
* - `flip_horizontal`
|
|
1111
|
-
* boolean optional flip the animation horizontally, the default value is false
|
|
1112
|
-
*
|
|
1113
|
-
* - `geometries`
|
|
1114
|
-
* table A list of the geometries that should map to the texture data. Supports the following fields:
|
|
1115
|
-
*
|
|
1116
|
-
* - `vertices`
|
|
1117
|
-
* table a list of the vertices in texture space of the geometry in the form {px0, py0, px1, py1, ..., pxn, pyn}
|
|
1118
|
-
*
|
|
1119
|
-
* - `uvs`
|
|
1120
|
-
* table a list of the uv coordinates in texture space of the geometry in the form of {u0, v0, u1, v1, ..., un, vn}
|
|
1121
|
-
*
|
|
1122
|
-
* - `indices`
|
|
1123
|
-
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
1260
|
+
* @param table - atlas data. **⚠️ `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
1261
|
* @example
|
|
1125
1262
|
* Add a new animation to an existing atlas
|
|
1126
1263
|
* ```ts
|
|
@@ -1136,9 +1273,25 @@ declare global {
|
|
|
1136
1273
|
* frame_end: 6,
|
|
1137
1274
|
* playback: go.PLAYBACK_LOOP_PINGPONG,
|
|
1138
1275
|
* fps: 8,
|
|
1276
|
+
* flip_vertical: false,
|
|
1277
|
+
* flip_horizontal: false,
|
|
1139
1278
|
* };
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1279
|
+
* // set_atlas takes each animation's frames as a non-empty list
|
|
1280
|
+
* const animations = data.animations.flatMap((animation) => {
|
|
1281
|
+
* // an animation described by frame_start/frame_end passes through as-is
|
|
1282
|
+
* if (!("frames" in animation)) return [animation];
|
|
1283
|
+
* const [first, ...rest] = (animation.frames as number[] | undefined) ?? [];
|
|
1284
|
+
* return first === undefined ? [] : [{ ...animation, frames: [first, ...rest] as [number, ...number[]] }];
|
|
1285
|
+
* });
|
|
1286
|
+
* // set_atlas needs at least one animation and one geometry
|
|
1287
|
+
* const [first_geometry, ...geometries] = data.geometries;
|
|
1288
|
+
* if (first_geometry !== undefined) {
|
|
1289
|
+
* resource.set_atlas("/main/my_atlas.a.texturesetc", {
|
|
1290
|
+
* ...data,
|
|
1291
|
+
* animations: [my_animation, ...animations],
|
|
1292
|
+
* geometries: [first_geometry, ...geometries],
|
|
1293
|
+
* });
|
|
1294
|
+
* }
|
|
1142
1295
|
* },
|
|
1143
1296
|
* });
|
|
1144
1297
|
* ```
|
|
@@ -1165,13 +1318,13 @@ declare global {
|
|
|
1165
1318
|
* indices: [0, 1, 2, 0, 2, 3],
|
|
1166
1319
|
* },
|
|
1167
1320
|
* ],
|
|
1168
|
-
* };
|
|
1321
|
+
* } satisfies Parameters<typeof resource.set_atlas>[1];
|
|
1169
1322
|
* resource.set_atlas("/main/test.a.texturesetc", params);
|
|
1170
1323
|
* },
|
|
1171
1324
|
* });
|
|
1172
1325
|
* ```
|
|
1173
1326
|
*/
|
|
1174
|
-
function set_atlas(path: Hash | string, table:
|
|
1327
|
+
function set_atlas(path: Hash | string, table: resource.atlas): void;
|
|
1175
1328
|
/**
|
|
1176
1329
|
* Sets the buffer of a resource. By default, setting the resource buffer will either copy the data from the incoming buffer object
|
|
1177
1330
|
* 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
|
|
@@ -1183,10 +1336,7 @@ declare global {
|
|
|
1183
1336
|
*
|
|
1184
1337
|
* @param path - The path to the resource
|
|
1185
1338
|
* @param buffer - The resource buffer
|
|
1186
|
-
* @param table -
|
|
1187
|
-
*
|
|
1188
|
-
* - `transfer_ownership`
|
|
1189
|
-
* boolean optional flag to determine whether or not the resource should take over ownership of the buffer object (default false)
|
|
1339
|
+
* @param table - optional buffer-resource update options
|
|
1190
1340
|
* @example
|
|
1191
1341
|
* ```ts
|
|
1192
1342
|
* // How to set the data from a buffer
|
|
@@ -1198,7 +1348,7 @@ declare global {
|
|
|
1198
1348
|
*
|
|
1199
1349
|
* export default defineScript({
|
|
1200
1350
|
* init() {
|
|
1201
|
-
* const res_path = go.get("#mesh", "vertices");
|
|
1351
|
+
* const res_path = go.get<mesh.properties>()("#mesh", "vertices");
|
|
1202
1352
|
*
|
|
1203
1353
|
* const positions = [
|
|
1204
1354
|
* 1, -1, 0,
|
|
@@ -1221,7 +1371,7 @@ declare global {
|
|
|
1221
1371
|
* });
|
|
1222
1372
|
* ```
|
|
1223
1373
|
*/
|
|
1224
|
-
function set_buffer(path: Hash | string, buffer: Opaque<"buffer">, table?:
|
|
1374
|
+
function set_buffer(path: Hash | string, buffer: Opaque<"buffer">, table?: resource.buffer_update_options): void;
|
|
1225
1375
|
/**
|
|
1226
1376
|
* Update internal sound resource (wavc/oggc/opusc) with new data
|
|
1227
1377
|
*
|
|
@@ -1233,109 +1383,52 @@ declare global {
|
|
|
1233
1383
|
* Sets the pixel data for a specific texture.
|
|
1234
1384
|
*
|
|
1235
1385
|
* @param path - The path to the resource
|
|
1236
|
-
* @param table -
|
|
1237
|
-
*
|
|
1238
|
-
* `type`
|
|
1239
|
-
* number The texture type. Supported values:
|
|
1240
|
-
*
|
|
1241
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
1242
|
-
*
|
|
1243
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
1244
|
-
*
|
|
1245
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
1246
|
-
*
|
|
1247
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
1248
|
-
*
|
|
1249
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
1250
|
-
*
|
|
1251
|
-
* `width`
|
|
1252
|
-
* number The width of the texture (in pixels)
|
|
1253
|
-
* `height`
|
|
1254
|
-
* number The width of the texture (in pixels)
|
|
1255
|
-
* `format`
|
|
1256
|
-
* number The texture format, note that some of these formats are platform specific. Supported values:
|
|
1257
|
-
*
|
|
1258
|
-
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
1259
|
-
*
|
|
1260
|
-
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
1261
|
-
*
|
|
1262
|
-
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
1263
|
-
*
|
|
1264
|
-
* These constants might not be available on the device:
|
|
1265
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
1266
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
1267
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
1268
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
1269
|
-
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
1270
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
1271
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
1272
|
-
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
1273
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
1274
|
-
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
1275
|
-
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
1276
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
1277
|
-
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
1278
|
-
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
1279
|
-
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
1280
|
-
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
1281
|
-
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
1282
|
-
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
1283
|
-
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
1284
|
-
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
1285
|
-
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
1286
|
-
*
|
|
1287
|
-
* `if graphics.TEXTURE_FORMAT_RGBA16F ~= nil then
|
|
1288
|
-
* -- it is safe to use this format
|
|
1289
|
-
* end
|
|
1290
|
-
* `
|
|
1291
|
-
*
|
|
1292
|
-
* `x`
|
|
1293
|
-
* number optional x offset of the texture (in pixels)
|
|
1294
|
-
* `y`
|
|
1295
|
-
* number optional y offset of the texture (in pixels)
|
|
1296
|
-
* `z`
|
|
1297
|
-
* number optional z offset of the texture (in pixels). Only applies to 3D textures
|
|
1298
|
-
* `page`
|
|
1299
|
-
* number optional slice of the array texture. Only applies to 2D texture arrays. Zero-based
|
|
1300
|
-
* `mipmap`
|
|
1301
|
-
* number optional mipmap to upload the data to
|
|
1302
|
-
* `compression_type`
|
|
1303
|
-
* 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
|
-
*
|
|
1305
|
-
* - `COMPRESSION_TYPE_DEFAULT`
|
|
1306
|
-
*
|
|
1307
|
-
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
1386
|
+
* @param table - texture update parameters. **0️⃣ `page` is 0-based; passed to Defold unchanged.** **0️⃣ `mipmap` is 0-based; passed to Defold unchanged.**
|
|
1308
1387
|
* @param buffer - The buffer of precreated pixel data
|
|
1309
1388
|
* 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
|
-
* 3D
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1389
|
+
* 3D textures are currently only supported on OpenGL and Vulkan adapters.
|
|
1390
|
+
* @example
|
|
1391
|
+
* Check whether a texture format is supported by the device:
|
|
1392
|
+
* ```ts
|
|
1393
|
+
* if (graphics.TEXTURE_FORMAT_RGBA16F !== undefined) {
|
|
1394
|
+
* // It is safe to use this format.
|
|
1395
|
+
* }
|
|
1396
|
+
* ```
|
|
1397
|
+
* @example
|
|
1398
|
+
* Check whether the device supports 3D textures before using them:
|
|
1399
|
+
* ```ts
|
|
1400
|
+
* if (graphics.TEXTURE_TYPE_3D !== undefined) {
|
|
1401
|
+
* // The device and graphics adapter support 3D textures.
|
|
1402
|
+
* }
|
|
1315
1403
|
* ```
|
|
1316
1404
|
* @example
|
|
1317
1405
|
* How to set all pixels of an atlas
|
|
1318
1406
|
* ```ts
|
|
1319
1407
|
* // How to set all pixels of an atlas
|
|
1320
1408
|
* 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
|
-
*
|
|
1409
|
+
* init() {
|
|
1410
|
+
* const height = 128;
|
|
1411
|
+
* const width = 128;
|
|
1412
|
+
* const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
1413
|
+
* const stream = buffer.get_stream(buf, hash("rgb"));
|
|
1414
|
+
*
|
|
1415
|
+
* for (let y = 0; y < height; y++) {
|
|
1416
|
+
* for (let x = 0; x < width; x++) {
|
|
1417
|
+
* const index = y * width * 3 + x * 3;
|
|
1418
|
+
* stream[index + 0] = 0xff;
|
|
1419
|
+
* stream[index + 1] = 0x80;
|
|
1420
|
+
* stream[index + 2] = 0x10;
|
|
1333
1421
|
* }
|
|
1334
1422
|
* }
|
|
1335
1423
|
*
|
|
1336
|
-
*
|
|
1337
|
-
* const
|
|
1338
|
-
*
|
|
1424
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1425
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1426
|
+
* if (format !== undefined) {
|
|
1427
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1428
|
+
* const args = { width, height, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };
|
|
1429
|
+
* resource.set_texture(resource_path, args, buf);
|
|
1430
|
+
* }
|
|
1431
|
+
* return { buffer: buf, stream };
|
|
1339
1432
|
* },
|
|
1340
1433
|
* });
|
|
1341
1434
|
* ```
|
|
@@ -1344,26 +1437,31 @@ declare global {
|
|
|
1344
1437
|
* ```ts
|
|
1345
1438
|
* // 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
1439
|
* export default defineScript({
|
|
1347
|
-
* init(
|
|
1348
|
-
*
|
|
1349
|
-
*
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
* for (let
|
|
1356
|
-
* for (let
|
|
1357
|
-
* const index =
|
|
1358
|
-
*
|
|
1359
|
-
*
|
|
1360
|
-
*
|
|
1440
|
+
* init() {
|
|
1441
|
+
* const x = 16;
|
|
1442
|
+
* const y = 16;
|
|
1443
|
+
* const height = 128 - x * 2;
|
|
1444
|
+
* const width = 128 - y * 2;
|
|
1445
|
+
* const buf = buffer.create(width * height, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
1446
|
+
* const stream = buffer.get_stream(buf, hash("rgb"));
|
|
1447
|
+
*
|
|
1448
|
+
* for (let row = 0; row < height; row++) {
|
|
1449
|
+
* for (let col = 0; col < width; col++) {
|
|
1450
|
+
* const index = row * width * 3 + col * 3;
|
|
1451
|
+
* stream[index + 0] = 0xff;
|
|
1452
|
+
* stream[index + 1] = 0x80;
|
|
1453
|
+
* stream[index + 2] = 0x10;
|
|
1361
1454
|
* }
|
|
1362
1455
|
* }
|
|
1363
1456
|
*
|
|
1364
|
-
*
|
|
1365
|
-
* const
|
|
1366
|
-
*
|
|
1457
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1458
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1459
|
+
* if (format !== undefined) {
|
|
1460
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1461
|
+
* const args = { width, height, x, y, type: graphics.TEXTURE_TYPE_2D, format, num_mip_maps: 1 };
|
|
1462
|
+
* resource.set_texture(resource_path, args, buf);
|
|
1463
|
+
* }
|
|
1464
|
+
* return { buffer: buf, stream };
|
|
1367
1465
|
* },
|
|
1368
1466
|
* });
|
|
1369
1467
|
* ```
|
|
@@ -1371,17 +1469,22 @@ declare global {
|
|
|
1371
1469
|
* Update a texture from a buffer resource
|
|
1372
1470
|
* ```ts
|
|
1373
1471
|
* // Update a texture from a buffer resource
|
|
1374
|
-
* go.property("my_buffer", resource.buffer("/my_default_buffer.buffer"));
|
|
1375
|
-
*
|
|
1376
1472
|
* export default defineScript({
|
|
1473
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1474
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1475
|
+
* properties: { my_buffer: resource.buffer("/my_default_buffer.buffer") },
|
|
1476
|
+
*
|
|
1377
1477
|
* init(self) {
|
|
1378
|
-
*
|
|
1478
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1479
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1480
|
+
* if (format === undefined) return;
|
|
1481
|
+
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1379
1482
|
* // the "my_buffer" resource is expected to hold 128 * 128 * 3 bytes!
|
|
1380
1483
|
* const args = {
|
|
1381
1484
|
* width: 128,
|
|
1382
1485
|
* height: 128,
|
|
1383
1486
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
1384
|
-
* format
|
|
1487
|
+
* format,
|
|
1385
1488
|
* };
|
|
1386
1489
|
* // Note that the extra resource.get_buffer call is a requirement here
|
|
1387
1490
|
* // since the "self.my_buffer" is just pointing to a buffer resource path
|
|
@@ -1393,18 +1496,22 @@ declare global {
|
|
|
1393
1496
|
* @example
|
|
1394
1497
|
* Update an existing 3D texture from a lua buffer
|
|
1395
1498
|
* ```ts
|
|
1396
|
-
* // Update an existing 3D texture from a buffer
|
|
1499
|
+
* // Update an existing 3D texture from a lua buffer
|
|
1397
1500
|
* export default defineScript({
|
|
1398
1501
|
* init() {
|
|
1502
|
+
* // the engine registers a texture type or format only when the driver supports it
|
|
1503
|
+
* const type = graphics.TEXTURE_TYPE_IMAGE_3D;
|
|
1504
|
+
* const format = graphics.TEXTURE_FORMAT_RGBA32F;
|
|
1505
|
+
* if (type === undefined || format === undefined) return;
|
|
1399
1506
|
* // create a buffer that can hold the data of a 8x8x8 texture
|
|
1400
1507
|
* const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash("rgba"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);
|
|
1401
1508
|
* const tstream = buffer.get_stream(tbuffer, hash("rgba"));
|
|
1402
1509
|
*
|
|
1403
1510
|
* // populate the buffer with some data
|
|
1404
1511
|
* let index = 0;
|
|
1405
|
-
* for (let z =
|
|
1406
|
-
* for (let y =
|
|
1407
|
-
* for (let x =
|
|
1512
|
+
* for (let z = 1; z <= 8; z++) {
|
|
1513
|
+
* for (let y = 1; y <= 8; y++) {
|
|
1514
|
+
* for (let x = 1; x <= 8; x++) {
|
|
1408
1515
|
* tstream[index + 0] = x;
|
|
1409
1516
|
* tstream[index + 1] = y;
|
|
1410
1517
|
* tstream[index + 2] = z;
|
|
@@ -1415,11 +1522,11 @@ declare global {
|
|
|
1415
1522
|
* }
|
|
1416
1523
|
*
|
|
1417
1524
|
* const t_args = {
|
|
1418
|
-
* type
|
|
1525
|
+
* type,
|
|
1419
1526
|
* width: 8,
|
|
1420
1527
|
* height: 8,
|
|
1421
1528
|
* depth: 8,
|
|
1422
|
-
* format
|
|
1529
|
+
* format,
|
|
1423
1530
|
* };
|
|
1424
1531
|
*
|
|
1425
1532
|
* // This expects that the texture resource "/my_3d_texture.texturec" already exists
|
|
@@ -1430,11 +1537,14 @@ declare global {
|
|
|
1430
1537
|
* });
|
|
1431
1538
|
* ```
|
|
1432
1539
|
* @example
|
|
1540
|
+
* Update texture 2nd array page with loaded texture from png
|
|
1433
1541
|
* ```ts
|
|
1434
1542
|
* // Update texture 2nd array page with loaded texture from png
|
|
1435
1543
|
* const tex_path = "/bundle_resources/page_02.png";
|
|
1436
1544
|
* const [data] = sys.load_resource(tex_path);
|
|
1437
|
-
*
|
|
1545
|
+
* // the engine registers a texture format only when the driver supports it
|
|
1546
|
+
* const format = graphics.TEXTURE_FORMAT_RGB;
|
|
1547
|
+
* if (data !== undefined && format !== undefined) {
|
|
1438
1548
|
* const buf = image.load_buffer(data);
|
|
1439
1549
|
* if (buf !== undefined) {
|
|
1440
1550
|
* // new_tex is the resource handle of a texture created via resource.create_texture
|
|
@@ -1443,7 +1553,7 @@ declare global {
|
|
|
1443
1553
|
* width: buf.width,
|
|
1444
1554
|
* height: buf.height,
|
|
1445
1555
|
* page_count: 2,
|
|
1446
|
-
* format
|
|
1556
|
+
* format,
|
|
1447
1557
|
* });
|
|
1448
1558
|
* resource.set_texture(
|
|
1449
1559
|
* new_tex,
|
|
@@ -1452,7 +1562,7 @@ declare global {
|
|
|
1452
1562
|
* width: buf.width,
|
|
1453
1563
|
* height: buf.height,
|
|
1454
1564
|
* page: 1,
|
|
1455
|
-
* format
|
|
1565
|
+
* format,
|
|
1456
1566
|
* },
|
|
1457
1567
|
* buf.buffer,
|
|
1458
1568
|
* );
|
|
@@ -1461,24 +1571,25 @@ declare global {
|
|
|
1461
1571
|
* }
|
|
1462
1572
|
* ```
|
|
1463
1573
|
*/
|
|
1464
|
-
function set_texture(path: Hash | string, table:
|
|
1574
|
+
function set_texture(path: Hash | string, table: resource.texture_update_params, buffer: Opaque<"buffer">): void;
|
|
1465
1575
|
/**
|
|
1466
1576
|
* Constructor-like function with two purposes:
|
|
1467
1577
|
*
|
|
1468
1578
|
* - Load the specified resource as part of loading the script
|
|
1469
|
-
*
|
|
1470
|
-
* - Return a hash to the run-time version of the resource
|
|
1579
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
1471
1580
|
*
|
|
1472
1581
|
* This function can only be called within go.property function calls.
|
|
1473
1582
|
*
|
|
1474
1583
|
* @param path - optional resource path string to the resource
|
|
1475
|
-
* @returns a
|
|
1584
|
+
* @returns a reference to the binary version of the resource
|
|
1476
1585
|
* @example
|
|
1477
1586
|
* ```ts
|
|
1478
1587
|
* // Load a texture and set it to a model:
|
|
1479
|
-
* go.property("my_texture", resource.texture("/texture.png"));
|
|
1480
|
-
*
|
|
1481
1588
|
* export default defineScript({
|
|
1589
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1590
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1591
|
+
* properties: { my_texture: resource.texture("/texture.png") },
|
|
1592
|
+
*
|
|
1482
1593
|
* init(self) {
|
|
1483
1594
|
* go.set("#model", "texture0", self.my_texture);
|
|
1484
1595
|
* },
|
|
@@ -1490,19 +1601,20 @@ declare global {
|
|
|
1490
1601
|
* Constructor-like function with two purposes:
|
|
1491
1602
|
*
|
|
1492
1603
|
* - Load the specified resource as part of loading the script
|
|
1493
|
-
*
|
|
1494
|
-
* - Return a hash to the run-time version of the resource
|
|
1604
|
+
* - Create a resource reference that resolves to the hashed path of the run-time resource
|
|
1495
1605
|
*
|
|
1496
1606
|
* This function can only be called within go.property function calls.
|
|
1497
1607
|
*
|
|
1498
1608
|
* @param path - optional resource path string to the resource
|
|
1499
|
-
* @returns a
|
|
1609
|
+
* @returns a reference to the binary version of the resource
|
|
1500
1610
|
* @example
|
|
1501
1611
|
* ```ts
|
|
1502
1612
|
* // Load tile source and set it to a tile map:
|
|
1503
|
-
* go.property("my_tile_source", resource.tile_source("/tilesource.tilesource"));
|
|
1504
|
-
*
|
|
1505
1613
|
* export default defineScript({
|
|
1614
|
+
* // Never call `go.property` yourself: the transpiler emits the chunk-scope
|
|
1615
|
+
* // registration from this field, and only this field types the property onto `self`.
|
|
1616
|
+
* properties: { my_tile_source: resource.tile_source("/tilesource.tilesource") },
|
|
1617
|
+
*
|
|
1506
1618
|
* init(self) {
|
|
1507
1619
|
* go.set("#tilemap", "tile_source", self.my_tile_source);
|
|
1508
1620
|
* },
|