Skip to content

Commit

Permalink
Fix remove() error message
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha240100 committed Jul 19, 2016
1 parent 109afa0 commit 3cb7016
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 177 deletions.
10 changes: 5 additions & 5 deletions build/whitestorm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/whitestorm.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions examples/basic/helloworld/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';

var GAME = new WHS.World({
window.GAME = new WHS.World({
stats: 'fps', // fps, ms, mb
autoresize: true,

Expand All @@ -18,7 +18,7 @@ var GAME = new WHS.World({
}
});

new WHS.Sphere({
window.sphere = new WHS.Sphere({
geometry: {
radius: 3
},
Expand All @@ -35,7 +35,9 @@ new WHS.Sphere({
y: 100,
z: 0
}
}).addTo(GAME);
});

window.sphere.addTo(GAME);

new WHS.Plane({
geometry: {
Expand Down
10 changes: 5 additions & 5 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h4>Softbody <span>- example</span><span class="type"> - basic</span></h4>
</div></a>
</div>
<div class="item" style="background-image: url('./basic/threejs/screenshot.png');">
<a href="./basic/threjs/"><div class="splash">
<a href="./basic/threejs/"><div class="splash">
<h4>Three.js <span>- example</span><span class="type"> - basic</span></h4>
</div></a>
</div>
Expand Down Expand Up @@ -170,12 +170,12 @@ <h4>Dominoes <span>- example</span><span class="type"> - physics</span></h4>
<h4>Sticks <span>- example</span><span class="type"> - performance</span></h4>
</div></a>
</div>
<div class="item" style="background-image: url('./performance/softbodies/screenshot.png');">
<a href="./performance/softbodies/"><div class="splash">
<h4>Softbodies <span>- example</span><span class="type"> - performance</span></h4>

<div class="item placeholder">
<a href="#"><div class="splash">
<h4>Placeholder <span>- example</span><span class="type"> - basic</span></h4>
</div></a>
</div>

<div class="item placeholder">
<a href="#"><div class="splash">
<h4>Placeholder <span>- example</span><span class="type"> - basic</span></h4>
Expand Down
36 changes: 0 additions & 36 deletions examples/performance/softbodies/index.html

This file was deleted.

Binary file removed examples/performance/softbodies/screenshot.png
Binary file not shown.
116 changes: 0 additions & 116 deletions examples/performance/softbodies/script.js

This file was deleted.

10 changes: 7 additions & 3 deletions lib/physics/core/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ var Scene = exports.Scene = function (_THREE$Scene) {
var offset = 2 + index * _api.REPORT_ITEMSIZE;
var object = this._objects[data[offset]];

if (object === undefined) continue;
if (object === null) continue;

if (object.__dirtyPosition === false) {
object.position.set(data[offset + 1], data[offset + 2], data[offset + 3]);
Expand Down Expand Up @@ -202,6 +202,9 @@ var Scene = exports.Scene = function (_THREE$Scene) {
while (index--) {
var size = data[offset + 1];
var object = this._objects[data[offset]];

if (object === null) continue;

var association = object._physijs.aIdxAssoc;
var attributes = object.geometry.attributes;

Expand Down Expand Up @@ -258,7 +261,7 @@ var Scene = exports.Scene = function (_THREE$Scene) {
var offset = 1 + i * _api.VEHICLEREPORT_ITEMSIZE;
vehicle = this._vehicles[data[offset]];

if (vehicle === undefined) continue;
if (vehicle === null) continue;

wheel = vehicle.wheels[data[offset + 1]];

Expand Down Expand Up @@ -328,6 +331,7 @@ var Scene = exports.Scene = function (_THREE$Scene) {
for (var id1 in this._objects) {
if (!this._objects.hasOwnProperty(id1)) continue;
var _object = this._objects[id1];
if (_object === null) continue;

// If object touches anything, ...
if (collisions[id1]) {
Expand Down Expand Up @@ -552,7 +556,7 @@ var Scene = exports.Scene = function (_THREE$Scene) {

var object = this._objects[object_id];

if (object.__dirtyPosition || object.__dirtyRotation) {
if (object !== null && (object.__dirtyPosition || object.__dirtyRotation)) {
var update = { id: object._physijs.id };

if (object.__dirtyPosition) {
Expand Down
2 changes: 1 addition & 1 deletion lib/physics/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ module.exports = function (self) {
_vehicles[description.id] = vehicle;
};
public_functions.removeVehicle = function (description) {
delete _vehicles[description.id];
_vehicles[description.id] = null;
};

public_functions.addWheel = function (description) {
Expand Down
8 changes: 5 additions & 3 deletions src-examples/basic/helloworld/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const GAME = new WHS.World({
window.GAME = new WHS.World({
stats: 'fps', // fps, ms, mb
autoresize: true,

Expand All @@ -15,7 +15,7 @@ const GAME = new WHS.World({
}
});

new WHS.Sphere({
window.sphere = new WHS.Sphere({
geometry: {
radius: 3
},
Expand All @@ -32,7 +32,9 @@ new WHS.Sphere({
y: 100,
z: 0
}
}).addTo(GAME);
});

window.sphere.addTo(GAME);

new WHS.Plane({
geometry: {
Expand Down
10 changes: 7 additions & 3 deletions src/physics/core/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class Scene extends THREE.Scene {
const offset = 2 + index * REPORT_ITEMSIZE;
const object = this._objects[data[offset]];

if (object === undefined) continue;
if (object === null) continue;

if (object.__dirtyPosition === false) {
object.position.set(
Expand Down Expand Up @@ -182,6 +182,9 @@ export class Scene extends THREE.Scene {
while (index--) {
const size = data[offset + 1];
const object = this._objects[data[offset]];

if (object === null) continue;

const association = object._physijs.aIdxAssoc;
const attributes = object.geometry.attributes;

Expand Down Expand Up @@ -236,7 +239,7 @@ export class Scene extends THREE.Scene {
const offset = 1 + i * VEHICLEREPORT_ITEMSIZE;
vehicle = this._vehicles[data[offset]];

if (vehicle === undefined) continue;
if (vehicle === null) continue;

wheel = vehicle.wheels[data[offset + 1]];

Expand Down Expand Up @@ -318,6 +321,7 @@ export class Scene extends THREE.Scene {
for (const id1 in this._objects) {
if (!this._objects.hasOwnProperty(id1)) continue;
const object = this._objects[id1];
if (object === null) continue;

// If object touches anything, ...
if (collisions[id1]) {
Expand Down Expand Up @@ -562,7 +566,7 @@ export class Scene extends THREE.Scene {

const object = this._objects[object_id];

if (object.__dirtyPosition || object.__dirtyRotation) {
if (object !== null && (object.__dirtyPosition || object.__dirtyRotation)) {
const update = {id: object._physijs.id};

if (object.__dirtyPosition) {
Expand Down
2 changes: 1 addition & 1 deletion src/physics/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ module.exports = function (self) {
_vehicles[description.id] = vehicle;
};
public_functions.removeVehicle = (description) => {
delete _vehicles[description.id];
_vehicles[description.id] = null;
};

public_functions.addWheel = (description) => {
Expand Down

0 comments on commit 3cb7016

Please sign in to comment.