@defold-typescript/types 0.40.0 → 0.42.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 +3963 -772
- package/api-migrations.json +27 -0
- package/api-signatures.json +18069 -10240
- package/api-targets.json +448 -11
- package/examples/translations.json +560 -89
- 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 +183 -20
- package/generated/b2d_world.d.ts +57 -63
- package/generated/buffer.d.ts +16 -15
- 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 +29 -32
- package/generated/collectionfactory.d.ts +15 -18
- 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 +235 -182
- package/generated/graphics.d.ts +335 -97
- package/generated/gui.d.ts +240 -471
- package/generated/html5.d.ts +2 -2
- package/generated/http.d.ts +28 -35
- package/generated/image.d.ts +105 -72
- package/generated/json.d.ts +34 -16
- package/generated/kinds/gui-script.d.ts +7 -0
- package/generated/kinds/render-script.d.ts +7 -0
- package/generated/kinds/script.d.ts +7 -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 +40 -39
- package/generated/particlefx.d.ts +19 -28
- package/generated/physics.d.ts +365 -133
- package/generated/profiler.d.ts +13 -23
- package/generated/render.d.ts +237 -297
- package/generated/resource.d.ts +664 -583
- package/generated/socket.d.ts +120 -133
- package/generated/sound.d.ts +62 -31
- package/generated/sprite.d.ts +31 -17
- package/generated/sys.d.ts +234 -190
- 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 +1 -3
- package/generated/versions/defold-1.12.4/camera.d.ts +21 -21
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +9 -9
- 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 +6 -12
- package/generated/versions/defold-1.12.4/gui.d.ts +77 -175
- package/generated/versions/defold-1.12.4/html5.d.ts +1 -1
- package/generated/versions/defold-1.12.4/http.d.ts +0 -13
- package/generated/versions/defold-1.12.4/image.d.ts +16 -33
- package/generated/versions/defold-1.12.4/index.d.ts +1 -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 +2 -10
- package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.12.4/physics.d.ts +69 -67
- package/generated/versions/defold-1.12.4/profiler.d.ts +2 -5
- package/generated/versions/defold-1.12.4/render.d.ts +99 -128
- package/generated/versions/defold-1.12.4/resource.d.ts +120 -148
- package/generated/versions/defold-1.12.4/socket.d.ts +34 -60
- package/generated/versions/defold-1.12.4/sound.d.ts +8 -8
- package/generated/versions/defold-1.12.4/sprite.d.ts +15 -5
- package/generated/versions/defold-1.12.4/sys.d.ts +37 -71
- 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 +0 -21
- 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 +169 -8
- package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
- package/generated/versions/defold-1.13.0/buffer.d.ts +1 -3
- package/generated/versions/defold-1.13.0/camera.d.ts +25 -25
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +9 -9
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
- package/generated/versions/defold-1.13.0/compute.d.ts +0 -69
- 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 +6 -12
- package/generated/versions/defold-1.13.0/graphics.d.ts +73 -37
- package/generated/versions/defold-1.13.0/gui.d.ts +77 -175
- package/generated/versions/defold-1.13.0/html5.d.ts +1 -1
- package/generated/versions/defold-1.13.0/http.d.ts +0 -13
- package/generated/versions/defold-1.13.0/image.d.ts +16 -33
- package/generated/versions/defold-1.13.0/index.d.ts +1 -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 +68 -106
- package/generated/versions/defold-1.13.0/model.d.ts +2 -10
- package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
- package/generated/versions/defold-1.13.0/physics.d.ts +69 -67
- package/generated/versions/defold-1.13.0/profiler.d.ts +2 -5
- package/generated/versions/defold-1.13.0/render.d.ts +99 -128
- package/generated/versions/defold-1.13.0/resource.d.ts +126 -150
- package/generated/versions/defold-1.13.0/socket.d.ts +34 -60
- package/generated/versions/defold-1.13.0/sound.d.ts +8 -8
- package/generated/versions/defold-1.13.0/sprite.d.ts +15 -5
- package/generated/versions/defold-1.13.0/sys.d.ts +37 -71
- 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 +0 -21
- 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 +1 -21
- package/generated/window.d.ts +71 -71
- package/identity-vocabulary.json +561 -0
- package/index.d.ts +7 -0
- package/package.json +18 -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 +12 -2
- package/scripts/import-defold-release.ts +106 -26
- package/scripts/prose-constants.ts +77 -16
- package/scripts/regen.ts +391 -77
- package/scripts/shared-handle-methods.ts +53 -0
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/sync-api-docs.ts +48 -10
- package/src/api-availability.ts +0 -0
- package/src/api-doc.ts +201 -3
- package/src/api-identity.ts +252 -0
- package/src/core-types.ts +26 -3
- package/src/correction-pins.ts +49 -0
- package/src/doc-comment.ts +104 -11
- package/src/doc-corrections.ts +108 -0
- package/src/editor-vm-globals.d.ts +5 -2
- package/src/emit-dts.ts +2064 -281
- package/src/emit-messages.ts +52 -0
- 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 +25 -6
- package/src/index-base-table.ts +145 -0
- package/src/index-slot-classifications.ts +588 -0
- package/src/index.ts +38 -5
- 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 +8 -11
- package/src/render-overloads.d.ts +0 -15
- package/src/return-correction-provenance.ts +58 -16
- 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,17 +6,492 @@ 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
|
|
@@ -51,13 +526,12 @@ declare global {
|
|
|
51
526
|
* Constructor-like function with two purposes:
|
|
52
527
|
*
|
|
53
528
|
* - Load the specified resource as part of loading the script
|
|
54
|
-
*
|
|
55
|
-
* - 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
|
|
56
530
|
*
|
|
57
531
|
* This function can only be called within go.property function calls.
|
|
58
532
|
*
|
|
59
533
|
* @param path - optional resource path string to the resource
|
|
60
|
-
* @returns a
|
|
534
|
+
* @returns a reference to the binary version of the resource
|
|
61
535
|
* @example
|
|
62
536
|
* ```ts
|
|
63
537
|
* // Set a unique buffer it to a sprite:
|
|
@@ -86,82 +560,22 @@ declare global {
|
|
|
86
560
|
* and not necessarily that it will be deleted.
|
|
87
561
|
*
|
|
88
562
|
* @param path - The path to the resource.
|
|
89
|
-
* @param table -
|
|
90
|
-
*
|
|
91
|
-
* - `texture`
|
|
92
|
-
* string | hash the path to the texture resource, e.g "/main/my_texture.texturec"
|
|
93
|
-
*
|
|
94
|
-
* - `animations`
|
|
95
|
-
* table a list of the animations in the atlas. Supports the following fields:
|
|
96
|
-
*
|
|
97
|
-
* - `id`
|
|
98
|
-
* string the id of the animation, used in e.g sprite.play_animation
|
|
99
|
-
*
|
|
100
|
-
* - `width`
|
|
101
|
-
* number the width of the animation
|
|
102
|
-
*
|
|
103
|
-
* - `height`
|
|
104
|
-
* number the height of the animation
|
|
105
|
-
*
|
|
106
|
-
* - `frame_start`
|
|
107
|
-
* number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
|
|
108
|
-
*
|
|
109
|
-
* - `frame_end`
|
|
110
|
-
* number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
|
|
111
|
-
*
|
|
112
|
-
* - `playback`
|
|
113
|
-
* constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
|
|
114
|
-
*
|
|
115
|
-
* - `fps`
|
|
116
|
-
* number optional fps of the animation, the default value is 30
|
|
117
|
-
*
|
|
118
|
-
* - `flip_vertical`
|
|
119
|
-
* boolean optional flip the animation vertically, the default value is false
|
|
120
|
-
*
|
|
121
|
-
* - `flip_horizontal`
|
|
122
|
-
* boolean optional flip the animation horizontally, the default value is false
|
|
123
|
-
*
|
|
124
|
-
* - `geometries`
|
|
125
|
-
* table A list of the geometries that should map to the texture data. Supports the following fields:
|
|
126
|
-
*
|
|
127
|
-
* - `id`
|
|
128
|
-
* string The name of the geometry. Used when matching animations between multiple atlases
|
|
129
|
-
*
|
|
130
|
-
* - `width`
|
|
131
|
-
* number The width of the image the sprite geometry represents
|
|
132
|
-
*
|
|
133
|
-
* - `height`
|
|
134
|
-
* number The height of the image the sprite geometry represents
|
|
135
|
-
*
|
|
136
|
-
* - `pivot_x`
|
|
137
|
-
* number The pivot x value of the image in unit coords. (0,0) is upper left corner, (1,1) is bottom right. Default is 0.5.
|
|
138
|
-
*
|
|
139
|
-
* - `pivot_y`
|
|
140
|
-
* number The pivot y value of the image in unit coords. (0,0) is upper left corner, (1,1) is bottom right. Default is 0.5.
|
|
141
|
-
*
|
|
142
|
-
* - `rotated`
|
|
143
|
-
* boolean Whether the image is rotated 90 degrees counter-clockwise in the atlas. This affects UV coordinate generation for proper rendering. Default is false.
|
|
144
|
-
*
|
|
145
|
-
* - `vertices`
|
|
146
|
-
* table a list of the vertices in image space of the geometry in the form {px0, py0, px1, py1, ..., pxn, pyn}
|
|
147
|
-
*
|
|
148
|
-
* - `uvs`
|
|
149
|
-
* table a list of the uv coordinates in image space of the geometry in the form of {u0, v0, u1, v1, ..., un, vn}.
|
|
150
|
-
*
|
|
151
|
-
* - `indices`
|
|
152
|
-
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
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.**
|
|
153
564
|
* @returns Returns the atlas resource path
|
|
154
565
|
* @example
|
|
155
566
|
* ```ts
|
|
156
567
|
* // Create a backing texture and an atlas
|
|
157
568
|
* export default defineScript({
|
|
158
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;
|
|
159
573
|
* // create an empty texture
|
|
160
574
|
* const tparams = {
|
|
161
575
|
* width: 128,
|
|
162
576
|
* height: 128,
|
|
163
577
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
164
|
-
* format
|
|
578
|
+
* format,
|
|
165
579
|
* };
|
|
166
580
|
* const my_texture_id = resource.create_texture("/my_texture.texturec", tparams);
|
|
167
581
|
*
|
|
@@ -192,7 +606,7 @@ declare global {
|
|
|
192
606
|
* indices: [0, 1, 2, 0, 2, 3],
|
|
193
607
|
* },
|
|
194
608
|
* ],
|
|
195
|
-
* };
|
|
609
|
+
* } satisfies Parameters<typeof resource.create_atlas>[1];
|
|
196
610
|
* const my_atlas_id = resource.create_atlas("/my_atlas.texturesetc", aparams);
|
|
197
611
|
*
|
|
198
612
|
* // assign the atlas to the 'sprite' component on the same go
|
|
@@ -201,7 +615,7 @@ declare global {
|
|
|
201
615
|
* });
|
|
202
616
|
* ```
|
|
203
617
|
*/
|
|
204
|
-
function create_atlas(path: string, table:
|
|
618
|
+
function create_atlas(path: string, table: resource.atlas): Hash;
|
|
205
619
|
/**
|
|
206
620
|
* This function creates a new buffer resource that can be used in the same way as any buffer created during build time.
|
|
207
621
|
* The function requires a valid buffer created from either buffer.create or another pre-existing buffer resource.
|
|
@@ -213,13 +627,7 @@ declare global {
|
|
|
213
627
|
* The path must also be unique, attempting to create a buffer with the same name as an existing resource will raise an error.
|
|
214
628
|
*
|
|
215
629
|
* @param path - The path to the resource.
|
|
216
|
-
* @param table -
|
|
217
|
-
*
|
|
218
|
-
* - `buffer`
|
|
219
|
-
* buffer the buffer to bind to this resource
|
|
220
|
-
*
|
|
221
|
-
* - `transfer_ownership`
|
|
222
|
-
* 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
|
|
223
631
|
* @returns Returns the buffer resource path
|
|
224
632
|
* @example
|
|
225
633
|
* Create a buffer object and bind it to a buffer resource
|
|
@@ -274,20 +682,13 @@ declare global {
|
|
|
274
682
|
* });
|
|
275
683
|
* ```
|
|
276
684
|
*/
|
|
277
|
-
function create_buffer(path: string, table
|
|
685
|
+
function create_buffer(path: string, table: resource.buffer_creation_params): Hash;
|
|
278
686
|
/**
|
|
279
687
|
* Creates a sound data resource
|
|
280
688
|
* Supported formats are .oggc, .opusc and .wavc
|
|
281
689
|
*
|
|
282
690
|
* @param path - the path to the resource. Must not already exist.
|
|
283
|
-
* @param options -
|
|
284
|
-
*
|
|
285
|
-
* `data`
|
|
286
|
-
* string The raw data of the file. May be partial, but must include the header of the file
|
|
287
|
-
* `filesize`
|
|
288
|
-
* number If the file is partial, it must also specify the full size of the complete file.
|
|
289
|
-
* `partial`
|
|
290
|
-
* boolean Is the data not representing the full file, but just the initial chunk?
|
|
691
|
+
* @param options - optional sound-data parameters
|
|
291
692
|
* @returns the resulting path hash to the resource
|
|
292
693
|
* @example
|
|
293
694
|
* ```ts
|
|
@@ -307,7 +708,7 @@ declare global {
|
|
|
307
708
|
* });
|
|
308
709
|
* ```
|
|
309
710
|
*/
|
|
310
|
-
function create_sound_data(path: string, options
|
|
711
|
+
function create_sound_data(path: string, options: resource.sound_data_options): Hash;
|
|
311
712
|
/**
|
|
312
713
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
313
714
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -317,111 +718,22 @@ declare global {
|
|
|
317
718
|
* If the texture is created without a buffer, the pixel data will be blank.
|
|
318
719
|
*
|
|
319
720
|
* @param path - The path to the resource.
|
|
320
|
-
* @param table -
|
|
321
|
-
*
|
|
322
|
-
* `type`
|
|
323
|
-
* number The texture type. Supported values:
|
|
324
|
-
*
|
|
325
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
326
|
-
*
|
|
327
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
328
|
-
*
|
|
329
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
330
|
-
*
|
|
331
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
332
|
-
*
|
|
333
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
334
|
-
*
|
|
335
|
-
* `width`
|
|
336
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
337
|
-
* `height`
|
|
338
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
339
|
-
* `depth`
|
|
340
|
-
* 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`.
|
|
341
|
-
* `format`
|
|
342
|
-
* number The texture format, note that some of these formats might not be supported by the running device. Supported values:
|
|
343
|
-
*
|
|
344
|
-
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
345
|
-
*
|
|
346
|
-
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
347
|
-
*
|
|
348
|
-
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
349
|
-
*
|
|
350
|
-
* These constants might not be available on the device:
|
|
351
|
-
*
|
|
352
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
353
|
-
*
|
|
354
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
355
|
-
*
|
|
356
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
357
|
-
*
|
|
358
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
359
|
-
*
|
|
360
|
-
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
361
|
-
*
|
|
362
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
363
|
-
*
|
|
364
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
365
|
-
*
|
|
366
|
-
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
367
|
-
*
|
|
368
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
369
|
-
*
|
|
370
|
-
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
371
|
-
*
|
|
372
|
-
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
373
|
-
*
|
|
374
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
375
|
-
*
|
|
376
|
-
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
377
|
-
*
|
|
378
|
-
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
379
|
-
*
|
|
380
|
-
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
381
|
-
*
|
|
382
|
-
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
383
|
-
*
|
|
384
|
-
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
385
|
-
*
|
|
386
|
-
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
387
|
-
*
|
|
388
|
-
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
389
|
-
*
|
|
390
|
-
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
391
|
-
*
|
|
392
|
-
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
393
|
-
*
|
|
394
|
-
* `if graphics.TEXTURE_FORMAT_RGBA16F ~= nil then
|
|
395
|
-
* -- it is safe to use this format
|
|
396
|
-
* end
|
|
397
|
-
* `
|
|
398
|
-
*
|
|
399
|
-
* `flags`
|
|
400
|
-
* 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.
|
|
401
|
-
* 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:
|
|
402
|
-
*
|
|
403
|
-
* - `graphics.TEXTURE_USAGE_FLAG_SAMPLE` - The texture can be sampled from a shader (default)
|
|
404
|
-
*
|
|
405
|
-
* - `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
|
|
406
|
-
*
|
|
407
|
-
* - `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
|
|
408
|
-
*
|
|
409
|
-
* `max_mipmaps`
|
|
410
|
-
* number optional max number of mipmaps. Defaults to zero, i.e no mipmap support
|
|
411
|
-
* `compression_type`
|
|
412
|
-
* 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.
|
|
413
|
-
* 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:
|
|
414
|
-
*
|
|
415
|
-
* - `COMPRESSION_TYPE_DEFAULT`
|
|
416
|
-
*
|
|
417
|
-
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
721
|
+
* @param table - texture creation parameters
|
|
418
722
|
* @param buffer - optional buffer of precreated pixel data
|
|
419
723
|
* @returns The path to the resource.
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
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
|
+
* }
|
|
425
737
|
* ```
|
|
426
738
|
* @example
|
|
427
739
|
* How to create an 128x128 RGBA texture resource and assign it to a model
|
|
@@ -429,11 +741,14 @@ declare global {
|
|
|
429
741
|
* // How to create an 128x128 RGBA texture resource and assign it to a model
|
|
430
742
|
* export default defineScript({
|
|
431
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;
|
|
432
747
|
* const tparams = {
|
|
433
748
|
* width: 128,
|
|
434
749
|
* height: 128,
|
|
435
750
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
436
|
-
* format
|
|
751
|
+
* format,
|
|
437
752
|
* };
|
|
438
753
|
* const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams);
|
|
439
754
|
* go.set("#model", "texture0", my_texture_id);
|
|
@@ -446,6 +761,9 @@ declare global {
|
|
|
446
761
|
* // How to create an 128x128 floating point texture (RGBA32F) resource from a buffer object
|
|
447
762
|
* export default defineScript({
|
|
448
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;
|
|
449
767
|
* // Create a new buffer with 4 components and FLOAT32 type
|
|
450
768
|
* const tbuffer = buffer.create(128 * 128, [{ name: hash("rgba"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);
|
|
451
769
|
* const tstream = buffer.get_stream(tbuffer, hash("rgba"));
|
|
@@ -466,7 +784,7 @@ declare global {
|
|
|
466
784
|
* width: 128,
|
|
467
785
|
* height: 128,
|
|
468
786
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
469
|
-
* format
|
|
787
|
+
* format,
|
|
470
788
|
* };
|
|
471
789
|
*
|
|
472
790
|
* // Note that we pass the buffer as the last argument here!
|
|
@@ -483,12 +801,16 @@ declare global {
|
|
|
483
801
|
* // How to create a 32x32x32 floating point 3D texture that can be used to generate volumetric data in a compute shader
|
|
484
802
|
* export default defineScript({
|
|
485
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;
|
|
486
808
|
* const t_volume = resource.create_texture("/my_backing_texture.texturec", {
|
|
487
|
-
* type
|
|
809
|
+
* type,
|
|
488
810
|
* width: 32,
|
|
489
811
|
* height: 32,
|
|
490
812
|
* depth: 32,
|
|
491
|
-
* format
|
|
813
|
+
* format,
|
|
492
814
|
* flags: graphics.TEXTURE_USAGE_FLAG_STORAGE + graphics.TEXTURE_USAGE_FLAG_SAMPLE,
|
|
493
815
|
* });
|
|
494
816
|
*
|
|
@@ -501,16 +823,20 @@ declare global {
|
|
|
501
823
|
* How to create 512x512 texture array with 5 pages.
|
|
502
824
|
* ```ts
|
|
503
825
|
* // How to create 512x512 texture array with 5 pages.
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
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
|
+
* }
|
|
511
837
|
* ```
|
|
512
838
|
*/
|
|
513
|
-
function create_texture(path: string, table:
|
|
839
|
+
function create_texture(path: string, table: resource.texture_creation_params, buffer?: Opaque<"buffer">): Hash;
|
|
514
840
|
/**
|
|
515
841
|
* Creates a new texture resource that can be used in the same way as any texture created during build time.
|
|
516
842
|
* The path used for creating the texture must be unique, trying to create a resource at a path that is already
|
|
@@ -524,124 +850,46 @@ declare global {
|
|
|
524
850
|
* new texture. Be careful when using the initial texture handle handle as it will not be valid after the upload has finished.
|
|
525
851
|
*
|
|
526
852
|
* @param path - The path to the resource.
|
|
527
|
-
* @param table -
|
|
528
|
-
* `type`
|
|
529
|
-
* number The texture type. Supported values:
|
|
530
|
-
*
|
|
531
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
532
|
-
*
|
|
533
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
534
|
-
*
|
|
535
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
536
|
-
*
|
|
537
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
538
|
-
*
|
|
539
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
540
|
-
*
|
|
541
|
-
* `width`
|
|
542
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
543
|
-
* `height`
|
|
544
|
-
* number The width of the texture (in pixels). Must be larger than 0.
|
|
545
|
-
* `depth`
|
|
546
|
-
* 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`.
|
|
547
|
-
* `format`
|
|
548
|
-
* number The texture format, note that some of these formats might not be supported by the running device. Supported values:
|
|
549
|
-
*
|
|
550
|
-
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
551
|
-
*
|
|
552
|
-
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
553
|
-
*
|
|
554
|
-
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
555
|
-
*
|
|
556
|
-
* These constants might not be available on the device:
|
|
557
|
-
*
|
|
558
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
559
|
-
*
|
|
560
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
561
|
-
*
|
|
562
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
563
|
-
*
|
|
564
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
565
|
-
*
|
|
566
|
-
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
567
|
-
*
|
|
568
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
569
|
-
*
|
|
570
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
571
|
-
*
|
|
572
|
-
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
573
|
-
*
|
|
574
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
575
|
-
*
|
|
576
|
-
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
577
|
-
*
|
|
578
|
-
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
579
|
-
*
|
|
580
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
581
|
-
*
|
|
582
|
-
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
583
|
-
*
|
|
584
|
-
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
585
|
-
*
|
|
586
|
-
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
587
|
-
*
|
|
588
|
-
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
589
|
-
*
|
|
590
|
-
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
591
|
-
*
|
|
592
|
-
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
593
|
-
*
|
|
594
|
-
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
595
|
-
*
|
|
596
|
-
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
597
|
-
*
|
|
598
|
-
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
599
|
-
*
|
|
600
|
-
* `if graphics.TEXTURE_FORMAT_RGBA16F ~= nil then
|
|
601
|
-
* -- it is safe to use this format
|
|
602
|
-
* end
|
|
603
|
-
* `
|
|
604
|
-
*
|
|
605
|
-
* `flags`
|
|
606
|
-
* number Texture creation flags that can be used to dictate how the texture is created. Supported values:
|
|
607
|
-
*
|
|
608
|
-
* - `graphics.TEXTURE_USAGE_FLAG_SAMPLE` - The texture can be sampled from a shader (default)
|
|
609
|
-
*
|
|
610
|
-
* - `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
|
|
611
|
-
*
|
|
612
|
-
* - `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
|
|
613
|
-
*
|
|
614
|
-
* `max_mipmaps`
|
|
615
|
-
* number optional max number of mipmaps. Defaults to zero, i.e no mipmap support
|
|
616
|
-
* `compression_type`
|
|
617
|
-
* 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.
|
|
618
|
-
* 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:
|
|
619
|
-
*
|
|
620
|
-
* - `COMPRESSION_TYPE_DEFAULT`
|
|
621
|
-
*
|
|
622
|
-
* - `COMPRESSION_TYPE_BASIS_UASTC`
|
|
853
|
+
* @param table - texture creation parameters
|
|
623
854
|
* @param buffer - optional buffer of precreated pixel data
|
|
624
|
-
* @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
|
+
* ```
|
|
625
870
|
* @example
|
|
626
871
|
* Create a texture resource asyncronously with a buffer and a callback
|
|
627
872
|
* ```ts
|
|
628
873
|
* // Create a texture resource asyncronously with a buffer and a callback
|
|
629
|
-
* function callback(self: unknown, request_id:
|
|
874
|
+
* function callback(self: unknown, request_id: number, result: resource.texture_creation_result) {
|
|
630
875
|
* // The resource has been updated with a new texture,
|
|
631
876
|
* // so we can update other systems with the new handle,
|
|
632
877
|
* // or update components to use the resource if we want
|
|
633
|
-
* const tinfo = resource.get_texture_info(
|
|
878
|
+
* const tinfo = resource.get_texture_info(result.path);
|
|
634
879
|
* msg.post("@render:", "set_backing_texture", { handle: tinfo.handle });
|
|
635
880
|
* }
|
|
636
881
|
*
|
|
637
882
|
* export default defineScript({
|
|
638
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;
|
|
639
887
|
* // Create a texture resource async
|
|
640
888
|
* const tparams = {
|
|
641
889
|
* width: 128,
|
|
642
890
|
* height: 128,
|
|
643
891
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
644
|
-
* format
|
|
892
|
+
* format,
|
|
645
893
|
* };
|
|
646
894
|
*
|
|
647
895
|
* // Create a new buffer with 4 components
|
|
@@ -667,17 +915,20 @@ declare global {
|
|
|
667
915
|
* });
|
|
668
916
|
* ```
|
|
669
917
|
* @example
|
|
670
|
-
* Create a texture resource
|
|
918
|
+
* Create a texture resource asynchronously with a callback that does nothing
|
|
671
919
|
* ```ts
|
|
672
|
-
* // Create a texture resource asyncronously without
|
|
920
|
+
* // Create a texture resource asyncronously without handling its completion
|
|
673
921
|
* export default defineScript({
|
|
674
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;
|
|
675
926
|
* // Create a texture resource async
|
|
676
927
|
* const tparams = {
|
|
677
928
|
* width: 128,
|
|
678
929
|
* height: 128,
|
|
679
930
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
680
|
-
* format
|
|
931
|
+
* format,
|
|
681
932
|
* };
|
|
682
933
|
*
|
|
683
934
|
* // Create a new buffer with 4 components
|
|
@@ -695,7 +946,8 @@ declare global {
|
|
|
695
946
|
* }
|
|
696
947
|
* }
|
|
697
948
|
* // create the texture
|
|
698
|
-
*
|
|
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, () => {});
|
|
699
951
|
* // at this point you can use the resource as-is, but note that the texture will be a blank 1x1 texture
|
|
700
952
|
* // that will be removed once the new texture has been updated
|
|
701
953
|
* go.set("#model", "texture0", tpath);
|
|
@@ -703,18 +955,17 @@ declare global {
|
|
|
703
955
|
* });
|
|
704
956
|
* ```
|
|
705
957
|
*/
|
|
706
|
-
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]>;
|
|
707
959
|
/**
|
|
708
960
|
* Constructor-like function with two purposes:
|
|
709
961
|
*
|
|
710
962
|
* - Load the specified resource as part of loading the script
|
|
711
|
-
*
|
|
712
|
-
* - 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
|
|
713
964
|
*
|
|
714
965
|
* This function can only be called within go.property function calls.
|
|
715
966
|
*
|
|
716
967
|
* @param path - optional resource path string to the resource
|
|
717
|
-
* @returns a
|
|
968
|
+
* @returns a reference to the binary version of the resource
|
|
718
969
|
* @example
|
|
719
970
|
* Load a font and set it to a label:
|
|
720
971
|
* ```ts
|
|
@@ -749,19 +1000,9 @@ declare global {
|
|
|
749
1000
|
* Returns the atlas data for an atlas
|
|
750
1001
|
*
|
|
751
1002
|
* @param path - The path to the atlas resource
|
|
752
|
-
* @returns
|
|
753
|
-
*
|
|
754
|
-
* - texture
|
|
755
|
-
*
|
|
756
|
-
* - geometries
|
|
757
|
-
*
|
|
758
|
-
* - animations
|
|
759
|
-
*
|
|
760
|
-
* Each animation entry also contains a `frames` table with indices into
|
|
761
|
-
* `geometries`, preserving the frame-to-geometry mapping used by the atlas.
|
|
762
|
-
* 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.**
|
|
763
1004
|
*/
|
|
764
|
-
function get_atlas(path: Hash | string):
|
|
1005
|
+
function get_atlas(path: Hash | string): resource.atlas_data;
|
|
765
1006
|
/**
|
|
766
1007
|
* gets the buffer from a resource
|
|
767
1008
|
*
|
|
@@ -788,46 +1029,7 @@ declare global {
|
|
|
788
1029
|
* Gets render target info from a render target resource path or a render target handle
|
|
789
1030
|
*
|
|
790
1031
|
* @param path - The path to the resource or a render target handle
|
|
791
|
-
* @returns
|
|
792
|
-
*
|
|
793
|
-
* `handle`
|
|
794
|
-
* number the opaque handle to the texture resource
|
|
795
|
-
* 'attachments'
|
|
796
|
-
* table a table of attachments, where each attachment contains the following entries:
|
|
797
|
-
* `width`
|
|
798
|
-
* number width of the texture
|
|
799
|
-
* `height`
|
|
800
|
-
* number height of the texture
|
|
801
|
-
* `depth`
|
|
802
|
-
* number depth of the texture (i.e 1 for a 2D texture and 6 for a cube map)
|
|
803
|
-
* `mipmaps`
|
|
804
|
-
* number number of mipmaps of the texture
|
|
805
|
-
* `type`
|
|
806
|
-
* number The texture type. Supported values:
|
|
807
|
-
*
|
|
808
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
809
|
-
*
|
|
810
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
811
|
-
*
|
|
812
|
-
* - `graphics.TEXTURE_TYPE_2D_ARRAY`
|
|
813
|
-
*
|
|
814
|
-
* `buffer_type`
|
|
815
|
-
* number The attachment buffer type. Supported values:
|
|
816
|
-
*
|
|
817
|
-
* - `resource.BUFFER_TYPE_COLOR0`
|
|
818
|
-
*
|
|
819
|
-
* - `resource.BUFFER_TYPE_COLOR1`
|
|
820
|
-
*
|
|
821
|
-
* - `resource.BUFFER_TYPE_COLOR2`
|
|
822
|
-
*
|
|
823
|
-
* - `resource.BUFFER_TYPE_COLOR3`
|
|
824
|
-
*
|
|
825
|
-
* - `resource.BUFFER_TYPE_DEPTH`
|
|
826
|
-
*
|
|
827
|
-
* - `resource.BUFFER_TYPE_STENCIL`
|
|
828
|
-
*
|
|
829
|
-
* - `texture`
|
|
830
|
-
* 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
|
|
831
1033
|
* @example
|
|
832
1034
|
* Get the metadata from a render target resource
|
|
833
1035
|
* ```ts
|
|
@@ -857,31 +1059,16 @@ declare global {
|
|
|
857
1059
|
* });
|
|
858
1060
|
* ```
|
|
859
1061
|
*/
|
|
860
|
-
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;
|
|
861
1063
|
/**
|
|
862
|
-
* 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.
|
|
863
1067
|
*
|
|
864
1068
|
* @param url - the font to get the (unscaled) metrics from
|
|
865
1069
|
* @param text - text to measure
|
|
866
|
-
* @param options -
|
|
867
|
-
*
|
|
868
|
-
* `width`
|
|
869
|
-
* number The width of the text field. Not used if `line_break` is false.
|
|
870
|
-
* `leading`
|
|
871
|
-
* number The leading (default 1.0)
|
|
872
|
-
* `tracking`
|
|
873
|
-
* number The tracking (default 0.0)
|
|
874
|
-
* `line_break`
|
|
875
|
-
* boolean If the calculation should consider line breaks (default false)
|
|
876
|
-
* @returns a table with the following fields:
|
|
877
|
-
*
|
|
878
|
-
* - width
|
|
879
|
-
*
|
|
880
|
-
* - height
|
|
881
|
-
*
|
|
882
|
-
* - max_ascent
|
|
883
|
-
*
|
|
884
|
-
* - max_descent
|
|
1070
|
+
* @param options - optional text-metric options
|
|
1071
|
+
* @returns measured text metrics
|
|
885
1072
|
* @example
|
|
886
1073
|
* ```ts
|
|
887
1074
|
* export default defineScript({
|
|
@@ -893,53 +1080,27 @@ declare global {
|
|
|
893
1080
|
* });
|
|
894
1081
|
* ```
|
|
895
1082
|
*/
|
|
896
|
-
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;
|
|
897
1084
|
/**
|
|
898
1085
|
* Gets texture info from a texture resource path or a texture handle
|
|
899
1086
|
*
|
|
900
1087
|
* @param path - The path to the resource or a texture handle
|
|
901
|
-
* @returns
|
|
902
|
-
*
|
|
903
|
-
* `handle`
|
|
904
|
-
* number the opaque handle to the texture resource
|
|
905
|
-
* `width`
|
|
906
|
-
* number width of the texture
|
|
907
|
-
* `height`
|
|
908
|
-
* number height of the texture
|
|
909
|
-
* `depth`
|
|
910
|
-
* number depth of the texture (i.e 1 for a 2D texture, 6 for a cube map, the actual depth of a 3D texture)
|
|
911
|
-
* `page_count`
|
|
912
|
-
* number number of pages of the texture array. For 2D texture value is 1. For cube map - 6
|
|
913
|
-
* `mipmaps`
|
|
914
|
-
* number number of mipmaps of the texture
|
|
915
|
-
* `flags`
|
|
916
|
-
* number usage hints of the texture.
|
|
917
|
-
* `type`
|
|
918
|
-
* number The texture type. Supported values:
|
|
919
|
-
*
|
|
920
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
921
|
-
*
|
|
922
|
-
* - `graphics.TEXTURE_TYPE_2D_ARRAY`
|
|
923
|
-
*
|
|
924
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
925
|
-
*
|
|
926
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
927
|
-
*
|
|
928
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
929
|
-
*
|
|
930
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
1088
|
+
* @returns texture information
|
|
931
1089
|
* @example
|
|
932
1090
|
* Create a new texture and get the metadata from it
|
|
933
1091
|
* ```ts
|
|
934
1092
|
* // Create a new texture and get the metadata from it
|
|
935
1093
|
* export default defineScript({
|
|
936
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;
|
|
937
1098
|
* // create an empty texture
|
|
938
1099
|
* const tparams = {
|
|
939
1100
|
* width: 128,
|
|
940
1101
|
* height: 128,
|
|
941
1102
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
942
|
-
* format
|
|
1103
|
+
* format,
|
|
943
1104
|
* };
|
|
944
1105
|
*
|
|
945
1106
|
* const my_texture_path = resource.create_texture("/my_texture.texturec", tparams);
|
|
@@ -973,7 +1134,7 @@ declare global {
|
|
|
973
1134
|
* });
|
|
974
1135
|
* ```
|
|
975
1136
|
*/
|
|
976
|
-
function get_texture_info(path: Hash | string |
|
|
1137
|
+
function get_texture_info(path: Hash | string | Opaque<"texture"> | number): resource.texture_info;
|
|
977
1138
|
/**
|
|
978
1139
|
* Loads the resource data for a specific resource.
|
|
979
1140
|
*
|
|
@@ -983,9 +1144,11 @@ declare global {
|
|
|
983
1144
|
* ```ts
|
|
984
1145
|
* // read custom resource data into buffer
|
|
985
1146
|
* const buffer = resource.load("/resources/datafile");
|
|
986
|
-
*
|
|
987
|
-
*
|
|
988
|
-
*
|
|
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
|
|
989
1152
|
* // [project]
|
|
990
1153
|
* // title = My project
|
|
991
1154
|
* // version = 0.1
|
|
@@ -997,13 +1160,12 @@ declare global {
|
|
|
997
1160
|
* Constructor-like function with two purposes:
|
|
998
1161
|
*
|
|
999
1162
|
* - Load the specified resource as part of loading the script
|
|
1000
|
-
*
|
|
1001
|
-
* - 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
|
|
1002
1164
|
*
|
|
1003
1165
|
* This function can only be called within go.property function calls.
|
|
1004
1166
|
*
|
|
1005
1167
|
* @param path - optional resource path string to the resource
|
|
1006
|
-
* @returns a
|
|
1168
|
+
* @returns a reference to the binary version of the resource
|
|
1007
1169
|
* @example
|
|
1008
1170
|
* Load a material and set it to a sprite:
|
|
1009
1171
|
* ```ts
|
|
@@ -1045,13 +1207,12 @@ declare global {
|
|
|
1045
1207
|
* Constructor-like function with two purposes:
|
|
1046
1208
|
*
|
|
1047
1209
|
* - Load the specified resource as part of loading the script
|
|
1048
|
-
*
|
|
1049
|
-
* - 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
|
|
1050
1211
|
*
|
|
1051
1212
|
* This function can only be called within go.property function calls.
|
|
1052
1213
|
*
|
|
1053
1214
|
* @param path - optional resource path string to the resource
|
|
1054
|
-
* @returns a
|
|
1215
|
+
* @returns a reference to the binary version of the resource
|
|
1055
1216
|
* @example
|
|
1056
1217
|
* ```ts
|
|
1057
1218
|
* // Set a render target color attachment as a model texture:
|
|
@@ -1096,52 +1257,7 @@ declare global {
|
|
|
1096
1257
|
* this function.
|
|
1097
1258
|
*
|
|
1098
1259
|
* @param path - The path to the atlas resource
|
|
1099
|
-
* @param table -
|
|
1100
|
-
*
|
|
1101
|
-
* - `texture`
|
|
1102
|
-
* string | hash the path to the texture resource, e.g "/main/my_texture.texturec"
|
|
1103
|
-
*
|
|
1104
|
-
* - `animations`
|
|
1105
|
-
* table a list of the animations in the atlas. Supports the following fields:
|
|
1106
|
-
*
|
|
1107
|
-
* - `id`
|
|
1108
|
-
* string the id of the animation, used in e.g sprite.play_animation
|
|
1109
|
-
*
|
|
1110
|
-
* - `width`
|
|
1111
|
-
* number the width of the animation
|
|
1112
|
-
*
|
|
1113
|
-
* - `height`
|
|
1114
|
-
* number the height of the animation
|
|
1115
|
-
*
|
|
1116
|
-
* - `frame_start`
|
|
1117
|
-
* number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
|
|
1118
|
-
*
|
|
1119
|
-
* - `frame_end`
|
|
1120
|
-
* number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
|
|
1121
|
-
*
|
|
1122
|
-
* - `playback`
|
|
1123
|
-
* constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
|
|
1124
|
-
*
|
|
1125
|
-
* - `fps`
|
|
1126
|
-
* number optional fps of the animation, the default value is 30
|
|
1127
|
-
*
|
|
1128
|
-
* - `flip_vertical`
|
|
1129
|
-
* boolean optional flip the animation vertically, the default value is false
|
|
1130
|
-
*
|
|
1131
|
-
* - `flip_horizontal`
|
|
1132
|
-
* boolean optional flip the animation horizontally, the default value is false
|
|
1133
|
-
*
|
|
1134
|
-
* - `geometries`
|
|
1135
|
-
* table A list of the geometries that should map to the texture data. Supports the following fields:
|
|
1136
|
-
*
|
|
1137
|
-
* - `vertices`
|
|
1138
|
-
* table a list of the vertices in texture space of the geometry in the form {px0, py0, px1, py1, ..., pxn, pyn}
|
|
1139
|
-
*
|
|
1140
|
-
* - `uvs`
|
|
1141
|
-
* table a list of the uv coordinates in texture space of the geometry in the form of {u0, v0, u1, v1, ..., un, vn}
|
|
1142
|
-
*
|
|
1143
|
-
* - `indices`
|
|
1144
|
-
* table a list of the indices of the geometry in the form {i0, i1, i2, ..., in}. Each tripe in the list represents a triangle.
|
|
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.**
|
|
1145
1261
|
* @example
|
|
1146
1262
|
* Add a new animation to an existing atlas
|
|
1147
1263
|
* ```ts
|
|
@@ -1160,8 +1276,22 @@ declare global {
|
|
|
1160
1276
|
* flip_vertical: false,
|
|
1161
1277
|
* flip_horizontal: false,
|
|
1162
1278
|
* };
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
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
|
+
* }
|
|
1165
1295
|
* },
|
|
1166
1296
|
* });
|
|
1167
1297
|
* ```
|
|
@@ -1188,13 +1318,13 @@ declare global {
|
|
|
1188
1318
|
* indices: [0, 1, 2, 0, 2, 3],
|
|
1189
1319
|
* },
|
|
1190
1320
|
* ],
|
|
1191
|
-
* };
|
|
1321
|
+
* } satisfies Parameters<typeof resource.set_atlas>[1];
|
|
1192
1322
|
* resource.set_atlas("/main/test.a.texturesetc", params);
|
|
1193
1323
|
* },
|
|
1194
1324
|
* });
|
|
1195
1325
|
* ```
|
|
1196
1326
|
*/
|
|
1197
|
-
function set_atlas(path: Hash | string, table:
|
|
1327
|
+
function set_atlas(path: Hash | string, table: resource.atlas): void;
|
|
1198
1328
|
/**
|
|
1199
1329
|
* Sets the buffer of a resource. By default, setting the resource buffer will either copy the data from the incoming buffer object
|
|
1200
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
|
|
@@ -1206,10 +1336,7 @@ declare global {
|
|
|
1206
1336
|
*
|
|
1207
1337
|
* @param path - The path to the resource
|
|
1208
1338
|
* @param buffer - The resource buffer
|
|
1209
|
-
* @param table -
|
|
1210
|
-
*
|
|
1211
|
-
* - `transfer_ownership`
|
|
1212
|
-
* 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
|
|
1213
1340
|
* @example
|
|
1214
1341
|
* ```ts
|
|
1215
1342
|
* // How to set the data from a buffer
|
|
@@ -1244,7 +1371,7 @@ declare global {
|
|
|
1244
1371
|
* });
|
|
1245
1372
|
* ```
|
|
1246
1373
|
*/
|
|
1247
|
-
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;
|
|
1248
1375
|
/**
|
|
1249
1376
|
* Update internal sound resource (wavc/oggc/opusc) with new data
|
|
1250
1377
|
*
|
|
@@ -1256,85 +1383,23 @@ declare global {
|
|
|
1256
1383
|
* Sets the pixel data for a specific texture.
|
|
1257
1384
|
*
|
|
1258
1385
|
* @param path - The path to the resource
|
|
1259
|
-
* @param table -
|
|
1260
|
-
*
|
|
1261
|
-
* `type`
|
|
1262
|
-
* number The texture type. Supported values:
|
|
1263
|
-
*
|
|
1264
|
-
* - `graphics.TEXTURE_TYPE_2D`
|
|
1265
|
-
*
|
|
1266
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_2D`
|
|
1267
|
-
*
|
|
1268
|
-
* - `graphics.TEXTURE_TYPE_3D`
|
|
1269
|
-
*
|
|
1270
|
-
* - `graphics.TEXTURE_TYPE_IMAGE_3D`
|
|
1271
|
-
*
|
|
1272
|
-
* - `graphics.TEXTURE_TYPE_CUBE_MAP`
|
|
1273
|
-
*
|
|
1274
|
-
* `width`
|
|
1275
|
-
* number The width of the texture (in pixels)
|
|
1276
|
-
* `height`
|
|
1277
|
-
* number The width of the texture (in pixels)
|
|
1278
|
-
* `format`
|
|
1279
|
-
* number The texture format, note that some of these formats are platform specific. Supported values:
|
|
1280
|
-
*
|
|
1281
|
-
* - `graphics.TEXTURE_FORMAT_LUMINANCE`
|
|
1282
|
-
*
|
|
1283
|
-
* - `graphics.TEXTURE_FORMAT_RGB`
|
|
1284
|
-
*
|
|
1285
|
-
* - `graphics.TEXTURE_FORMAT_RGBA`
|
|
1286
|
-
*
|
|
1287
|
-
* These constants might not be available on the device:
|
|
1288
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_2BPPV1`
|
|
1289
|
-
* - `graphics.TEXTURE_FORMAT_RGB_PVRTC_4BPPV1`
|
|
1290
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_2BPPV1`
|
|
1291
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
|
|
1292
|
-
* - `graphics.TEXTURE_FORMAT_RGB_ETC1`
|
|
1293
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
|
|
1294
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
|
|
1295
|
-
* - `graphics.TEXTURE_FORMAT_RGB_BC1`
|
|
1296
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC3`
|
|
1297
|
-
* - `graphics.TEXTURE_FORMAT_R_BC4`
|
|
1298
|
-
* - `graphics.TEXTURE_FORMAT_RG_BC5`
|
|
1299
|
-
* - `graphics.TEXTURE_FORMAT_RGBA_BC7`
|
|
1300
|
-
* - `graphics.TEXTURE_FORMAT_RGB16F`
|
|
1301
|
-
* - `graphics.TEXTURE_FORMAT_RGB32F`
|
|
1302
|
-
* - `graphics.TEXTURE_FORMAT_RGBA16F`
|
|
1303
|
-
* - `graphics.TEXTURE_FORMAT_RGBA32F`
|
|
1304
|
-
* - `graphics.TEXTURE_FORMAT_R16F`
|
|
1305
|
-
* - `graphics.TEXTURE_FORMAT_RG16F`
|
|
1306
|
-
* - `graphics.TEXTURE_FORMAT_R32F`
|
|
1307
|
-
* - `graphics.TEXTURE_FORMAT_RG32F`
|
|
1308
|
-
* You can test if the device supports these values by checking if a specific enum is nil or not:
|
|
1309
|
-
*
|
|
1310
|
-
* `if graphics.TEXTURE_FORMAT_RGBA16F ~= nil then
|
|
1311
|
-
* -- it is safe to use this format
|
|
1312
|
-
* end
|
|
1313
|
-
* `
|
|
1314
|
-
*
|
|
1315
|
-
* `x`
|
|
1316
|
-
* number optional x offset of the texture (in pixels)
|
|
1317
|
-
* `y`
|
|
1318
|
-
* number optional y offset of the texture (in pixels)
|
|
1319
|
-
* `z`
|
|
1320
|
-
* number optional z offset of the texture (in pixels). Only applies to 3D textures
|
|
1321
|
-
* `page`
|
|
1322
|
-
* number optional slice of the array texture. Only applies to 2D texture arrays. Zero-based
|
|
1323
|
-
* `mipmap`
|
|
1324
|
-
* number optional mipmap to upload the data to
|
|
1325
|
-
* `compression_type`
|
|
1326
|
-
* 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:
|
|
1327
|
-
*
|
|
1328
|
-
* - `COMPRESSION_TYPE_DEFAULT`
|
|
1329
|
-
*
|
|
1330
|
-
* - `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.**
|
|
1331
1387
|
* @param buffer - The buffer of precreated pixel data
|
|
1332
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!
|
|
1333
|
-
* 3D
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
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
|
+
* }
|
|
1338
1403
|
* ```
|
|
1339
1404
|
* @example
|
|
1340
1405
|
* How to set all pixels of an atlas
|
|
@@ -1356,9 +1421,13 @@ declare global {
|
|
|
1356
1421
|
* }
|
|
1357
1422
|
* }
|
|
1358
1423
|
*
|
|
1359
|
-
*
|
|
1360
|
-
* const
|
|
1361
|
-
*
|
|
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
|
+
* }
|
|
1362
1431
|
* return { buffer: buf, stream };
|
|
1363
1432
|
* },
|
|
1364
1433
|
* });
|
|
@@ -1385,9 +1454,13 @@ declare global {
|
|
|
1385
1454
|
* }
|
|
1386
1455
|
* }
|
|
1387
1456
|
*
|
|
1388
|
-
*
|
|
1389
|
-
* const
|
|
1390
|
-
*
|
|
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
|
+
* }
|
|
1391
1464
|
* return { buffer: buf, stream };
|
|
1392
1465
|
* },
|
|
1393
1466
|
* });
|
|
@@ -1402,13 +1475,16 @@ declare global {
|
|
|
1402
1475
|
* properties: { my_buffer: resource.buffer("/my_default_buffer.buffer") },
|
|
1403
1476
|
*
|
|
1404
1477
|
* init(self) {
|
|
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;
|
|
1405
1481
|
* const resource_path = go.get<model.properties>()("#model", "texture0");
|
|
1406
1482
|
* // the "my_buffer" resource is expected to hold 128 * 128 * 3 bytes!
|
|
1407
1483
|
* const args = {
|
|
1408
1484
|
* width: 128,
|
|
1409
1485
|
* height: 128,
|
|
1410
1486
|
* type: graphics.TEXTURE_TYPE_2D,
|
|
1411
|
-
* format
|
|
1487
|
+
* format,
|
|
1412
1488
|
* };
|
|
1413
1489
|
* // Note that the extra resource.get_buffer call is a requirement here
|
|
1414
1490
|
* // since the "self.my_buffer" is just pointing to a buffer resource path
|
|
@@ -1420,18 +1496,22 @@ declare global {
|
|
|
1420
1496
|
* @example
|
|
1421
1497
|
* Update an existing 3D texture from a lua buffer
|
|
1422
1498
|
* ```ts
|
|
1423
|
-
* // Update an existing 3D texture from a buffer
|
|
1499
|
+
* // Update an existing 3D texture from a lua buffer
|
|
1424
1500
|
* export default defineScript({
|
|
1425
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;
|
|
1426
1506
|
* // create a buffer that can hold the data of a 8x8x8 texture
|
|
1427
1507
|
* const tbuffer = buffer.create(8 * 8 * 8, [{ name: hash("rgba"), type: buffer.VALUE_TYPE_FLOAT32, count: 4 }]);
|
|
1428
1508
|
* const tstream = buffer.get_stream(tbuffer, hash("rgba"));
|
|
1429
1509
|
*
|
|
1430
1510
|
* // populate the buffer with some data
|
|
1431
1511
|
* let index = 0;
|
|
1432
|
-
* for (let z =
|
|
1433
|
-
* for (let y =
|
|
1434
|
-
* 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++) {
|
|
1435
1515
|
* tstream[index + 0] = x;
|
|
1436
1516
|
* tstream[index + 1] = y;
|
|
1437
1517
|
* tstream[index + 2] = z;
|
|
@@ -1442,11 +1522,11 @@ declare global {
|
|
|
1442
1522
|
* }
|
|
1443
1523
|
*
|
|
1444
1524
|
* const t_args = {
|
|
1445
|
-
* type
|
|
1525
|
+
* type,
|
|
1446
1526
|
* width: 8,
|
|
1447
1527
|
* height: 8,
|
|
1448
1528
|
* depth: 8,
|
|
1449
|
-
* format
|
|
1529
|
+
* format,
|
|
1450
1530
|
* };
|
|
1451
1531
|
*
|
|
1452
1532
|
* // This expects that the texture resource "/my_3d_texture.texturec" already exists
|
|
@@ -1457,11 +1537,14 @@ declare global {
|
|
|
1457
1537
|
* });
|
|
1458
1538
|
* ```
|
|
1459
1539
|
* @example
|
|
1540
|
+
* Update texture 2nd array page with loaded texture from png
|
|
1460
1541
|
* ```ts
|
|
1461
1542
|
* // Update texture 2nd array page with loaded texture from png
|
|
1462
1543
|
* const tex_path = "/bundle_resources/page_02.png";
|
|
1463
1544
|
* const [data] = sys.load_resource(tex_path);
|
|
1464
|
-
*
|
|
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) {
|
|
1465
1548
|
* const buf = image.load_buffer(data);
|
|
1466
1549
|
* if (buf !== undefined) {
|
|
1467
1550
|
* // new_tex is the resource handle of a texture created via resource.create_texture
|
|
@@ -1470,7 +1553,7 @@ declare global {
|
|
|
1470
1553
|
* width: buf.width,
|
|
1471
1554
|
* height: buf.height,
|
|
1472
1555
|
* page_count: 2,
|
|
1473
|
-
* format
|
|
1556
|
+
* format,
|
|
1474
1557
|
* });
|
|
1475
1558
|
* resource.set_texture(
|
|
1476
1559
|
* new_tex,
|
|
@@ -1479,7 +1562,7 @@ declare global {
|
|
|
1479
1562
|
* width: buf.width,
|
|
1480
1563
|
* height: buf.height,
|
|
1481
1564
|
* page: 1,
|
|
1482
|
-
* format
|
|
1565
|
+
* format,
|
|
1483
1566
|
* },
|
|
1484
1567
|
* buf.buffer,
|
|
1485
1568
|
* );
|
|
@@ -1488,18 +1571,17 @@ declare global {
|
|
|
1488
1571
|
* }
|
|
1489
1572
|
* ```
|
|
1490
1573
|
*/
|
|
1491
|
-
function set_texture(path: Hash | string, table:
|
|
1574
|
+
function set_texture(path: Hash | string, table: resource.texture_update_params, buffer: Opaque<"buffer">): void;
|
|
1492
1575
|
/**
|
|
1493
1576
|
* Constructor-like function with two purposes:
|
|
1494
1577
|
*
|
|
1495
1578
|
* - Load the specified resource as part of loading the script
|
|
1496
|
-
*
|
|
1497
|
-
* - 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
|
|
1498
1580
|
*
|
|
1499
1581
|
* This function can only be called within go.property function calls.
|
|
1500
1582
|
*
|
|
1501
1583
|
* @param path - optional resource path string to the resource
|
|
1502
|
-
* @returns a
|
|
1584
|
+
* @returns a reference to the binary version of the resource
|
|
1503
1585
|
* @example
|
|
1504
1586
|
* ```ts
|
|
1505
1587
|
* // Load a texture and set it to a model:
|
|
@@ -1519,13 +1601,12 @@ declare global {
|
|
|
1519
1601
|
* Constructor-like function with two purposes:
|
|
1520
1602
|
*
|
|
1521
1603
|
* - Load the specified resource as part of loading the script
|
|
1522
|
-
*
|
|
1523
|
-
* - 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
|
|
1524
1605
|
*
|
|
1525
1606
|
* This function can only be called within go.property function calls.
|
|
1526
1607
|
*
|
|
1527
1608
|
* @param path - optional resource path string to the resource
|
|
1528
|
-
* @returns a
|
|
1609
|
+
* @returns a reference to the binary version of the resource
|
|
1529
1610
|
* @example
|
|
1530
1611
|
* ```ts
|
|
1531
1612
|
* // Load tile source and set it to a tile map:
|