Skip to content

Commit deab5bd

Browse files
committed
build v1.3.0
1 parent 8bb96dc commit deab5bd

18 files changed

+394
-23
lines changed

.changeset/gentle-colts-hunt.md

-5
This file was deleted.

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# planck
22

3+
## 1.3.0
4+
5+
### Minor Changes
6+
7+
- 8bb96dc: Add DataDriver (experimental for demo use-case)
8+
39
## 1.2.0
410

511
### Minor Changes

dist/planck-with-testbed.d.ts

+17
Original file line numberDiff line numberDiff line change
@@ -4223,6 +4223,23 @@ export declare const internal: {
42234223
toString(newline?: string): string;
42244224
};
42254225
};
4226+
export interface DataDriverInterface<D, R> {
4227+
key: (body: D) => string;
4228+
create: (d: D) => R | null;
4229+
destroy: (d: D, ref: R) => void;
4230+
update: (d: D, ref: R) => void;
4231+
}
4232+
/**
4233+
* @experimental
4234+
*
4235+
* A DataDriver is used it to create, update and destroy physics entities based on game objects.
4236+
*/
4237+
export declare class DataDriver<D extends object, R> {
4238+
constructor(driver: DataDriverInterface<D, R>);
4239+
update(data: (D | null)[]): void;
4240+
ref(d: D): R;
4241+
private _delta;
4242+
}
42264243

42274244
export {
42284245
Body$1 as Body,

dist/planck-with-testbed.js

+85-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.planck = {}));
33
})(this, function(exports2) {
44
"use strict";/**
5-
* Planck.js v1.2.0
5+
* Planck.js v1.3.0
66
* @license The MIT license
77
* @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba
88
*
@@ -11677,6 +11677,88 @@
1167711677
DynamicTree,
1167811678
stats: stats$1
1167911679
};
11680+
var DataDriver = (
11681+
/** @class */
11682+
function() {
11683+
function DataDriver2(driver) {
11684+
var _this = this;
11685+
this.refMap = {};
11686+
this._key = function(d2) {
11687+
return _this.driver.key(d2);
11688+
};
11689+
this._enter = function(d2) {
11690+
var key = _this._key(d2);
11691+
var ref = _this.driver.create(d2);
11692+
if (ref) {
11693+
_this.refMap[key] = ref;
11694+
}
11695+
};
11696+
this._exit = function(d2) {
11697+
var key = _this._key(d2);
11698+
var ref = _this.refMap[key];
11699+
_this.driver.destroy(d2, ref);
11700+
delete _this.refMap[key];
11701+
};
11702+
this._update = function(d2) {
11703+
var key = _this._key(d2);
11704+
var ref = _this.refMap[key];
11705+
_this.driver.update(d2, ref);
11706+
};
11707+
this._map = {};
11708+
this._xmap = {};
11709+
this._data = [];
11710+
this._entered = [];
11711+
this._exited = [];
11712+
this.driver = driver;
11713+
}
11714+
DataDriver2.prototype.update = function(data) {
11715+
this._delta(data, this._key, this._enter, this._exit, this._update);
11716+
};
11717+
DataDriver2.prototype.ref = function(d2) {
11718+
return this.refMap[this._key(d2)];
11719+
};
11720+
DataDriver2.prototype._delta = function(data, key, enter, exit, update) {
11721+
if (!Array.isArray(data))
11722+
throw "Invalid data: " + data;
11723+
this._entered.length = 0;
11724+
this._exited.length = 0;
11725+
this._data.length = data.length;
11726+
for (var i = 0; i < data.length; i++) {
11727+
if (typeof data[i] !== "object" || data[i] === null)
11728+
continue;
11729+
var d2 = data[i];
11730+
var id = key(d2);
11731+
if (!this._map[id]) {
11732+
this._entered.push(d2);
11733+
} else {
11734+
delete this._map[id];
11735+
}
11736+
this._data[i] = d2;
11737+
this._xmap[id] = d2;
11738+
}
11739+
for (var id in this._map) {
11740+
this._exited.push(this._map[id]);
11741+
delete this._map[id];
11742+
}
11743+
var temp3 = this._map;
11744+
this._map = this._xmap;
11745+
this._xmap = temp3;
11746+
for (var i = 0; i < this._exited.length; i++) {
11747+
exit(this._exited[i]);
11748+
}
11749+
for (var i = 0; i < this._entered.length; i++) {
11750+
enter(this._entered[i]);
11751+
}
11752+
for (var i = 0; i < this._data.length; i++) {
11753+
update(this._data[i]);
11754+
}
11755+
this._entered.length = 0;
11756+
this._exited.length = 0;
11757+
this._data.length = 0;
11758+
};
11759+
return DataDriver2;
11760+
}()
11761+
);
1168011762
/**
1168111763
* Stage.js 1.0.0-alpha.5
1168211764
*
@@ -15933,6 +16015,7 @@
1593316015
},
1593416016
ContactID,
1593516017
ContactImpulse,
16018+
DataDriver,
1593616019
Distance,
1593716020
DistanceInput,
1593816021
DistanceJoint,
@@ -16023,6 +16106,7 @@
1602316106
exports2.ContactEdge = ContactEdge;
1602416107
exports2.ContactID = ContactID;
1602516108
exports2.ContactImpulse = ContactImpulse;
16109+
exports2.DataDriver = DataDriver;
1602616110
exports2.Distance = Distance;
1602716111
exports2.DistanceInput = DistanceInput;
1602816112
exports2.DistanceJoint = DistanceJoint;

dist/planck-with-testbed.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/planck-with-testbed.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/planck-with-testbed.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/planck-with-testbed.mjs

+85-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Planck.js v1.2.0
2+
* Planck.js v1.3.0
33
* @license The MIT license
44
* @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba
55
*
@@ -11673,6 +11673,88 @@ var internal = {
1167311673
DynamicTree,
1167411674
stats: stats$1
1167511675
};
11676+
var DataDriver = (
11677+
/** @class */
11678+
function() {
11679+
function DataDriver2(driver) {
11680+
var _this = this;
11681+
this.refMap = {};
11682+
this._key = function(d2) {
11683+
return _this.driver.key(d2);
11684+
};
11685+
this._enter = function(d2) {
11686+
var key = _this._key(d2);
11687+
var ref = _this.driver.create(d2);
11688+
if (ref) {
11689+
_this.refMap[key] = ref;
11690+
}
11691+
};
11692+
this._exit = function(d2) {
11693+
var key = _this._key(d2);
11694+
var ref = _this.refMap[key];
11695+
_this.driver.destroy(d2, ref);
11696+
delete _this.refMap[key];
11697+
};
11698+
this._update = function(d2) {
11699+
var key = _this._key(d2);
11700+
var ref = _this.refMap[key];
11701+
_this.driver.update(d2, ref);
11702+
};
11703+
this._map = {};
11704+
this._xmap = {};
11705+
this._data = [];
11706+
this._entered = [];
11707+
this._exited = [];
11708+
this.driver = driver;
11709+
}
11710+
DataDriver2.prototype.update = function(data) {
11711+
this._delta(data, this._key, this._enter, this._exit, this._update);
11712+
};
11713+
DataDriver2.prototype.ref = function(d2) {
11714+
return this.refMap[this._key(d2)];
11715+
};
11716+
DataDriver2.prototype._delta = function(data, key, enter, exit, update) {
11717+
if (!Array.isArray(data))
11718+
throw "Invalid data: " + data;
11719+
this._entered.length = 0;
11720+
this._exited.length = 0;
11721+
this._data.length = data.length;
11722+
for (var i = 0; i < data.length; i++) {
11723+
if (typeof data[i] !== "object" || data[i] === null)
11724+
continue;
11725+
var d2 = data[i];
11726+
var id = key(d2);
11727+
if (!this._map[id]) {
11728+
this._entered.push(d2);
11729+
} else {
11730+
delete this._map[id];
11731+
}
11732+
this._data[i] = d2;
11733+
this._xmap[id] = d2;
11734+
}
11735+
for (var id in this._map) {
11736+
this._exited.push(this._map[id]);
11737+
delete this._map[id];
11738+
}
11739+
var temp3 = this._map;
11740+
this._map = this._xmap;
11741+
this._xmap = temp3;
11742+
for (var i = 0; i < this._exited.length; i++) {
11743+
exit(this._exited[i]);
11744+
}
11745+
for (var i = 0; i < this._entered.length; i++) {
11746+
enter(this._entered[i]);
11747+
}
11748+
for (var i = 0; i < this._data.length; i++) {
11749+
update(this._data[i]);
11750+
}
11751+
this._entered.length = 0;
11752+
this._exited.length = 0;
11753+
this._data.length = 0;
11754+
};
11755+
return DataDriver2;
11756+
}()
11757+
);
1167611758
/**
1167711759
* Stage.js 1.0.0-alpha.5
1167811760
*
@@ -15929,6 +16011,7 @@ const planck = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
1592916011
},
1593016012
ContactID,
1593116013
ContactImpulse,
16014+
DataDriver,
1593216015
Distance,
1593316016
DistanceInput,
1593416017
DistanceJoint,
@@ -16021,6 +16104,7 @@ export {
1602116104
ContactFeatureType,
1602216105
ContactID,
1602316106
ContactImpulse,
16107+
DataDriver,
1602416108
Distance,
1602516109
DistanceInput,
1602616110
DistanceJoint,

dist/planck-with-testbed.mjs.map

+1-1
Large diffs are not rendered by default.

dist/planck.d.ts

+17
Original file line numberDiff line numberDiff line change
@@ -4223,6 +4223,23 @@ export declare const internal: {
42234223
toString(newline?: string): string;
42244224
};
42254225
};
4226+
export interface DataDriverInterface<D, R> {
4227+
key: (body: D) => string;
4228+
create: (d: D) => R | null;
4229+
destroy: (d: D, ref: R) => void;
4230+
update: (d: D, ref: R) => void;
4231+
}
4232+
/**
4233+
* @experimental
4234+
*
4235+
* A DataDriver is used it to create, update and destroy physics entities based on game objects.
4236+
*/
4237+
export declare class DataDriver<D extends object, R> {
4238+
constructor(driver: DataDriverInterface<D, R>);
4239+
update(data: (D | null)[]): void;
4240+
ref(d: D): R;
4241+
private _delta;
4242+
}
42264243

42274244
export {
42284245
Body$1 as Body,

0 commit comments

Comments
 (0)