Skip to content

Commit

Permalink
build v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiba committed Dec 27, 2024
1 parent 8bb96dc commit deab5bd
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 23 deletions.
5 changes: 0 additions & 5 deletions .changeset/gentle-colts-hunt.md

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# planck

## 1.3.0

### Minor Changes

- 8bb96dc: Add DataDriver (experimental for demo use-case)

## 1.2.0

### Minor Changes
Expand Down
17 changes: 17 additions & 0 deletions dist/planck-with-testbed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4223,6 +4223,23 @@ export declare const internal: {
toString(newline?: string): string;
};
};
export interface DataDriverInterface<D, R> {
key: (body: D) => string;
create: (d: D) => R | null;
destroy: (d: D, ref: R) => void;
update: (d: D, ref: R) => void;
}
/**
* @experimental
*
* A DataDriver is used it to create, update and destroy physics entities based on game objects.
*/
export declare class DataDriver<D extends object, R> {
constructor(driver: DataDriverInterface<D, R>);
update(data: (D | null)[]): void;
ref(d: D): R;
private _delta;
}

export {
Body$1 as Body,
Expand Down
86 changes: 85 additions & 1 deletion dist/planck-with-testbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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 = {}));
})(this, function(exports2) {
"use strict";/**
* Planck.js v1.2.0
* Planck.js v1.3.0
* @license The MIT license
* @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -11677,6 +11677,88 @@
DynamicTree,
stats: stats$1
};
var DataDriver = (
/** @class */
function() {
function DataDriver2(driver) {
var _this = this;
this.refMap = {};
this._key = function(d2) {
return _this.driver.key(d2);
};
this._enter = function(d2) {
var key = _this._key(d2);
var ref = _this.driver.create(d2);
if (ref) {
_this.refMap[key] = ref;
}
};
this._exit = function(d2) {
var key = _this._key(d2);
var ref = _this.refMap[key];
_this.driver.destroy(d2, ref);
delete _this.refMap[key];
};
this._update = function(d2) {
var key = _this._key(d2);
var ref = _this.refMap[key];
_this.driver.update(d2, ref);
};
this._map = {};
this._xmap = {};
this._data = [];
this._entered = [];
this._exited = [];
this.driver = driver;
}
DataDriver2.prototype.update = function(data) {
this._delta(data, this._key, this._enter, this._exit, this._update);
};
DataDriver2.prototype.ref = function(d2) {
return this.refMap[this._key(d2)];
};
DataDriver2.prototype._delta = function(data, key, enter, exit, update) {
if (!Array.isArray(data))
throw "Invalid data: " + data;
this._entered.length = 0;
this._exited.length = 0;
this._data.length = data.length;
for (var i = 0; i < data.length; i++) {
if (typeof data[i] !== "object" || data[i] === null)
continue;
var d2 = data[i];
var id = key(d2);
if (!this._map[id]) {
this._entered.push(d2);
} else {
delete this._map[id];
}
this._data[i] = d2;
this._xmap[id] = d2;
}
for (var id in this._map) {
this._exited.push(this._map[id]);
delete this._map[id];
}
var temp3 = this._map;
this._map = this._xmap;
this._xmap = temp3;
for (var i = 0; i < this._exited.length; i++) {
exit(this._exited[i]);
}
for (var i = 0; i < this._entered.length; i++) {
enter(this._entered[i]);
}
for (var i = 0; i < this._data.length; i++) {
update(this._data[i]);
}
this._entered.length = 0;
this._exited.length = 0;
this._data.length = 0;
};
return DataDriver2;
}()
);
/**
* Stage.js 1.0.0-alpha.5
*
Expand Down Expand Up @@ -15933,6 +16015,7 @@
},
ContactID,
ContactImpulse,
DataDriver,
Distance,
DistanceInput,
DistanceJoint,
Expand Down Expand Up @@ -16023,6 +16106,7 @@
exports2.ContactEdge = ContactEdge;
exports2.ContactID = ContactID;
exports2.ContactImpulse = ContactImpulse;
exports2.DataDriver = DataDriver;
exports2.Distance = Distance;
exports2.DistanceInput = DistanceInput;
exports2.DistanceJoint = DistanceJoint;
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/planck-with-testbed.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/planck-with-testbed.min.js.map

Large diffs are not rendered by default.

86 changes: 85 additions & 1 deletion dist/planck-with-testbed.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Planck.js v1.2.0
* Planck.js v1.3.0
* @license The MIT license
* @copyright Copyright (c) 2024 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -11673,6 +11673,88 @@ var internal = {
DynamicTree,
stats: stats$1
};
var DataDriver = (
/** @class */
function() {
function DataDriver2(driver) {
var _this = this;
this.refMap = {};
this._key = function(d2) {
return _this.driver.key(d2);
};
this._enter = function(d2) {
var key = _this._key(d2);
var ref = _this.driver.create(d2);
if (ref) {
_this.refMap[key] = ref;
}
};
this._exit = function(d2) {
var key = _this._key(d2);
var ref = _this.refMap[key];
_this.driver.destroy(d2, ref);
delete _this.refMap[key];
};
this._update = function(d2) {
var key = _this._key(d2);
var ref = _this.refMap[key];
_this.driver.update(d2, ref);
};
this._map = {};
this._xmap = {};
this._data = [];
this._entered = [];
this._exited = [];
this.driver = driver;
}
DataDriver2.prototype.update = function(data) {
this._delta(data, this._key, this._enter, this._exit, this._update);
};
DataDriver2.prototype.ref = function(d2) {
return this.refMap[this._key(d2)];
};
DataDriver2.prototype._delta = function(data, key, enter, exit, update) {
if (!Array.isArray(data))
throw "Invalid data: " + data;
this._entered.length = 0;
this._exited.length = 0;
this._data.length = data.length;
for (var i = 0; i < data.length; i++) {
if (typeof data[i] !== "object" || data[i] === null)
continue;
var d2 = data[i];
var id = key(d2);
if (!this._map[id]) {
this._entered.push(d2);
} else {
delete this._map[id];
}
this._data[i] = d2;
this._xmap[id] = d2;
}
for (var id in this._map) {
this._exited.push(this._map[id]);
delete this._map[id];
}
var temp3 = this._map;
this._map = this._xmap;
this._xmap = temp3;
for (var i = 0; i < this._exited.length; i++) {
exit(this._exited[i]);
}
for (var i = 0; i < this._entered.length; i++) {
enter(this._entered[i]);
}
for (var i = 0; i < this._data.length; i++) {
update(this._data[i]);
}
this._entered.length = 0;
this._exited.length = 0;
this._data.length = 0;
};
return DataDriver2;
}()
);
/**
* Stage.js 1.0.0-alpha.5
*
Expand Down Expand Up @@ -15929,6 +16011,7 @@ const planck = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
},
ContactID,
ContactImpulse,
DataDriver,
Distance,
DistanceInput,
DistanceJoint,
Expand Down Expand Up @@ -16021,6 +16104,7 @@ export {
ContactFeatureType,
ContactID,
ContactImpulse,
DataDriver,
Distance,
DistanceInput,
DistanceJoint,
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.mjs.map

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions dist/planck.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4223,6 +4223,23 @@ export declare const internal: {
toString(newline?: string): string;
};
};
export interface DataDriverInterface<D, R> {
key: (body: D) => string;
create: (d: D) => R | null;
destroy: (d: D, ref: R) => void;
update: (d: D, ref: R) => void;
}
/**
* @experimental
*
* A DataDriver is used it to create, update and destroy physics entities based on game objects.
*/
export declare class DataDriver<D extends object, R> {
constructor(driver: DataDriverInterface<D, R>);
update(data: (D | null)[]): void;
ref(d: D): R;
private _delta;
}

export {
Body$1 as Body,
Expand Down
Loading

0 comments on commit deab5bd

Please sign in to comment.