var Home = pc.createScript('home');
// initialize code called once per entity
Home.prototype.initialize = function() {
console.log("update");
//entityPlacement();
}
Home.prototype.update = function(dt) {
console.log("update");
};
...
I have tried getting rid of everything else but the console.log().
Other scripts like Network.js have no problem initializing.
I tried rearranging the script loading order and even tried to call initialize manually but to no avail.
Once this is working I need to also debug raytracing. home.js is supposed to be a debugger for an error i see in my development environment (self-hosted):
playcanvas-stable.min.js:6 Uncaught TypeError: s.get_m_closestHitFraction is not a function
at i.raycastFirst (playcanvas-stable.min.js:6:1190954)
at Raycast.doRaycast (raycast.js:59:45)
at Raycast.doSelect (raycast.js:46:14)
at Raycast.mouseDown (raycast.js:30:12)
at t.fire (playcanvas-stable.min.js:6:19995)
at i._handleDown (playcanvas-stable.min.js:6:234456)
i.raycastFirst @ playcanvas-stable.min.js:6
Raycast.doRaycast @ raycast.js:59
Raycast.doSelect @ raycast.js:46
Raycast.mouseDown @ raycast.js:30
t.fire @ playcanvas-stable.min.js:6
i._handleDown @ playcanvas-stable.min.js:6
It’s loading now. Some new problem came up - the raycast.js isnt being ‘enabled’. But I put a fix just for this project (read on if you are interested)
Try it again you should now see the error message .
Raycast.prototype.mouseDown = function (e) {
if (this.inputEnabled) {
this.doSelect(e);
}
};
...
Raycast.prototype.enableInput = function () {
this.inputEnabled = true;
};
whenever mouseDown is called (after home script has loaded and has executed raycastEntity.enableInput() …),
clicking and triggering mouseDown does not call doSelect() because this.inputEnabled is For Some Reason turned back to false.
It is only doing this in Playcanvas… So I just set inputEnabled = true in Raycast.prototype.initialize(). It’s triggering the mouseDown events now.
And again it is the the same error message I mentioned: get_m_closestHitFraction is not a function
debug.js:85 Powered by PlayCanvas 1.65.5 026dc4259
debug.js:107 WARNING: This version of ammo.js can potentially fail to report contacts. Please update it to the latest version.
warn @ debug.js:107
messenger.js:78 messenger connected
system.js:535 Uncaught TypeError: rayCallback.get_m_closestHitFraction is not a function
at RigidBodyComponentSystem.raycastFirst (system.js:535:33)
at Raycast.doRaycast (raycast.js?id=4608603&branchId=1624a7ae-8e76-465d-8a1c-6f8e6de4ac27:47:45)
at Raycast.mouseDown (raycast.js?id=4608603&branchId=1624a7ae-8e76-465d-8a1c-6f8e6de4ac27:29:10)
at Mouse.fire (event-handler.js:240:26)
at Mouse._handleDown (mouse.js:273:14)
system.js:535 Uncaught TypeError: rayCallback.get_m_closestHitFraction is not a function
at RigidBodyComponentSystem.raycastFirst (system.js:535:33)
at Raycast.doRaycast (raycast.js?id=4608603&branchId=1624a7ae-8e76-465d-8a1c-6f8e6de4ac27:47:45)
at Raycast.mouseDown (raycast.js?id=4608603&branchId=1624a7ae-8e76-465d-8a1c-6f8e6de4ac27:29:10)
at Mouse.fire (event-handler.js:240:26)
at Mouse._handleDown (mouse.js:273:14)