Skip to content

Commit c33d919

Browse files
Site changes [skip-ci]
1 parent a2abc2d commit c33d919

File tree

1,059 files changed

+8797
-3960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,059 files changed

+8797
-3960
lines changed

_includes/examples/render/screen_to_world/bee_script.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
local DISPLAY_WIDTH = sys.get_config_int("display.width")
2-
local DISPLAY_HEIGHT = sys.get_config_int("display.height")
3-
41
-- function to convert screen (mouse/touch) coordinates to
52
-- world coordinates given a camera component
63
-- this function will use the camera view and projection to
@@ -9,11 +6,13 @@ local function screen_to_world(x, y, z, camera_id)
96
local projection = camera.get_projection(camera_id)
107
local view = camera.get_view(camera_id)
118
local w, h = window.get_size()
9+
1210
-- The window.get_size() function will return the scaled window size,
1311
-- ie taking into account display scaling (Retina screens on macOS for
1412
-- instance). We need to adjust for display scaling in our calculation.
15-
w = w / (w / DISPLAY_WIDTH)
16-
h = h / (h / DISPLAY_HEIGHT)
13+
local scale = window.get_display_scale()
14+
w = w / scale
15+
h = h / scale
1716

1817
-- https://defold.com/manuals/camera/#converting-mouse-to-world-coordinates
1918
local inv = vmath.inv(projection * view)
Binary file not shown.

examples/animation/basic_tween/Defoldexamples_asmjs.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

examples/animation/basic_tween/Defoldexamples_pthread_wasm.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/animation/basic_tween/Defoldexamples_wasm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"content":[{"name":"game.projectc","size":4103,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":1408,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":38692,"pieces":[{"name":"game0.arcd","offset":0}]},{"name":"game.dmanifest","size":1585,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}],"total_size":45950}
1+
{"content":[{"name":"game.projectc","size":4138,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":1408,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":38692,"pieces":[{"name":"game0.arcd","offset":0}]},{"name":"game.dmanifest","size":1585,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}],"total_size":45985}
Binary file not shown.
Binary file not shown.
Binary file not shown.

examples/animation/basic_tween/archive/game0.projectc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ output_spirv = 0
7171

7272
[sound]
7373
gain = 1
74+
use_linear_gain = 1
7475
max_sound_data = 128
7576
max_sound_buffers = 32
7677
max_sound_sources = 16
@@ -201,6 +202,7 @@ subpixels = 1
201202

202203
[profiler]
203204
track_cpu = 0
205+
enabled = true
204206
sleep_between_server_updates = 0
205207

206208
[liveupdate]
Binary file not shown.

examples/animation/basic_tween/dmloader.js

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,17 @@ var FileLoader = {
217217

218218

219219
var EngineLoader = {
220-
221-
222-
wasm_size: 3062145,
223-
224-
wasmjs_size: 264303,
225-
226-
asmjs_size: 6013906,
220+
arc_sha1: "",
221+
wasm_sha1: "",
222+
wasm_size: 3077401,
223+
wasmjs_sha1: "",
224+
wasmjs_size: 273435,
225+
wasm_pthread_sha1: "",
226+
wasm_pthread_size: 3097270,
227+
wasmjs_pthread_sha1: "",
228+
wasmjs_pthread_size: 262080,
229+
asmjs_sha1: "",
230+
asmjs_size: 6043095,
227231
wasm_instantiate_progress: 0,
228232

229233
stream_wasm: "false" === "true",
@@ -232,6 +236,42 @@ var EngineLoader = {
232236
EngineLoader.wasm_instantiate_progress = totalDownloadedSize * 0.1;
233237
},
234238

239+
getWasmSize: function() {
240+
if (Module['isWASMPthreadSupported'])
241+
return EngineLoader.wasm_pthread_size;
242+
return EngineLoader.wasm_size;
243+
},
244+
245+
getWasmJSSize: function() {
246+
if (Module['isWASMPthreadSupported'])
247+
return EngineLoader.wasmjs_pthread_size;
248+
return EngineLoader.wasmjs_size;
249+
},
250+
251+
getWasmSha1: function() {
252+
if (Module['isWASMPthreadSupported'])
253+
return EngineLoader.wasm_pthread_sha1;
254+
return EngineLoader.wasm_sha1;
255+
},
256+
257+
getWasmJSSha1: function() {
258+
if (Module['isWASMPthreadSupported'])
259+
return EngineLoader.wasmjs_pthread_sha1;
260+
return EngineLoader.wasmjs_sha1;
261+
},
262+
263+
getWasmName: function(exeName) {
264+
if (Module['isWASMPthreadSupported'])
265+
return exeName + '_pthread.wasm';
266+
return exeName + '.wasm';
267+
},
268+
269+
getWasmJSName: function(exeName) {
270+
if (Module['isWASMPthreadSupported'])
271+
return exeName + '_pthread_wasm.js';
272+
return exeName + '_wasm.js';
273+
},
274+
235275
// load and instantiate .wasm file using XMLHttpRequest
236276
loadAndInstantiateWasmAsync: function(src, imports, successCallback) {
237277
FileLoader.load(src, "arraybuffer",
@@ -240,14 +280,14 @@ var EngineLoader = {
240280
},
241281
function(error) { throw error; },
242282
async function(wasm) {
243-
if (wasm.byteLength != EngineLoader.wasm_size) {
244-
console.warn("Unexpected wasm size: " + wasm.byteLength + ", expected: " + EngineLoader.wasm_size);
283+
if (wasm.byteLength != EngineLoader.getWasmSize()) {
284+
console.warn("Unexpected wasm size: " + wasm.byteLength + ", expected: " + EngineLoader.getWasmSize());
245285
}
246-
if (EngineLoader.wasm_sha1) {
286+
if (EngineLoader.getWasmSha1()) {
247287
const digest = await window.crypto.subtle.digest("SHA-1", wasm);
248288
const sha1 = Array.from(new Uint8Array(digest)).map(b => b.toString(16).padStart(2, '0')).join('');
249-
if (sha1 != EngineLoader.wasm_sha1) {
250-
const error = new Error("Unexpected wasm sha1: " + sha1 + ", expected: " + EngineLoader.wasm_sha1);
289+
if (sha1 != EngineLoader.getWasmSha1()) {
290+
const error = new Error("Unexpected wasm sha1: " + sha1 + ", expected: " + EngineLoader.getWasmSha1());
251291
if (typeof CUSTOM_PARAMETERS["start_error"] === "function") {
252292
CUSTOM_PARAMETERS["start_error"](error);
253293
}
@@ -256,7 +296,7 @@ var EngineLoader = {
256296
}
257297
var wasmInstantiate = WebAssembly.instantiate(new Uint8Array(wasm), imports).then(function(output) {
258298
Module.instance = output.instance;
259-
successCallback(output.instance);
299+
successCallback(output.instance, output.module);
260300
}).catch(function(e) {
261301
console.log('wasm instantiation failed! ' + e);
262302
if (typeof CUSTOM_PARAMETERS["start_error"] === "function") {
@@ -296,7 +336,7 @@ var EngineLoader = {
296336
WebAssembly.instantiateStreaming(fetchFn(src), imports).then(function(output) {
297337
ProgressUpdater.updateCurrent(EngineLoader.wasm_instantiate_progress);
298338
Module.instance = output.instance;
299-
successCallback(output.instance);
339+
successCallback(output.instance, output.module);
300340
}).catch(function(e) {
301341
console.log('wasm streaming instantiation failed! ' + e);
302342
console.log('Fallback to wasm loading');
@@ -321,14 +361,15 @@ var EngineLoader = {
321361
callback(imports);
322362
}
323363
if (EngineLoader.stream_wasm && (typeof WebAssembly.instantiateStreaming === "function")) {
324-
EngineLoader.streamAndInstantiateWasmAsync(exeName + ".wasm", imports, successCallback);
364+
EngineLoader.streamAndInstantiateWasmAsync(EngineLoader.getWasmName(exeName), imports, successCallback);
325365
}
326366
else {
327-
EngineLoader.loadAndInstantiateWasmAsync(exeName + ".wasm", imports, successCallback);
367+
EngineLoader.loadAndInstantiateWasmAsync(EngineLoader.getWasmName(exeName), imports, successCallback);
328368
}
329369
return {}; // Compiling asynchronously, no exports.
330370
};
331-
EngineLoader.loadAndRunScriptAsync(exeName + '_wasm.js', EngineLoader.wasmjs_size, EngineLoader.wasmjs_sha1);
371+
372+
EngineLoader.loadAndRunScriptAsync(EngineLoader.getWasmJSName(exeName), EngineLoader.getWasmJSSize(), EngineLoader.getWasmJSSha1());
332373
},
333374

334375
loadAsmJsAsync: function(exeName) {
@@ -358,9 +399,12 @@ var EngineLoader = {
358399
}
359400
}
360401
}
361-
var tag = document.createElement("script");
362-
tag.text = response;
363-
document.body.appendChild(tag);
402+
Module["mainScriptUrlOrBlob"] = src;
403+
404+
const script = document.createElement('script');
405+
script.src = src;
406+
script.type = "text/javascript";
407+
document.body.appendChild(script);
364408
},
365409
function(loadedDelta, currentAttempt){
366410
ProgressUpdater.updateCurrent(-loadedDelta);
@@ -515,7 +559,7 @@ var GameArchiveLoader = {
515559
var isWASMSupported = Module['isWASMSupported'];
516560
if (isWASMSupported) {
517561
EngineLoader.loadWasmAsync(exeName);
518-
totalSize += EngineLoader.wasm_size + EngineLoader.wasmjs_size;
562+
totalSize += EngineLoader.getWasmSize() + EngineLoader.getWasmJSSize();
519563
} else {
520564
EngineLoader.loadAsmJsAsync(exeName);
521565
totalSize += EngineLoader.asmjs_size;
@@ -841,8 +885,8 @@ var Progress = {
841885
/* ********************************************************************* */
842886

843887
var Module = {
844-
engineVersion: "1.10.1",
845-
engineSdkSha1: "d8e6e73a8efac6b9a72783027867e547b6a363e4",
888+
engineVersion: "1.10.2",
889+
engineSdkSha1: "7a0e23b3fcab4c5db82f2b32f5d8ac5df9467c9d",
846890
noInitialRun: true,
847891

848892
_filesToPreload: [],
@@ -1219,12 +1263,20 @@ Module['onRuntimeInitialized'] = function() {
12191263
Module.runApp("canvas");
12201264
};
12211265

1266+
Module["isWASMPthreadSupported"] = true
1267+
&& ((typeof window === 'undefined') || window.isSecureContext && window.crossOriginIsolated)
1268+
&& typeof SharedArrayBuffer !== 'undefined';
1269+
12221270
Module["locateFile"] = function(path, scriptDirectory)
12231271
{
12241272
// dmengine*.wasm is hardcoded in the built JS loader for WASM,
12251273
// we need to replace it here with the correct project name.
12261274
if (path == "dmengine.wasm" || path == "dmengine_release.wasm" || path == "dmengine_headless.wasm") {
1227-
path = "Defoldexamples.wasm";
1275+
if (Module['isWASMPthreadSupported']) {
1276+
path = "Defoldexamples_pthread.wasm";
1277+
} else {
1278+
path = "Defoldexamples.wasm";
1279+
}
12281280
}
12291281
return scriptDirectory + path;
12301282
};
Binary file not shown.

0 commit comments

Comments
 (0)