Error migrating from cannon.js to cannon-es - cannon.js

I have a world with cannon.js physics working fine. When I try to migrate to cannon-es I get an error in the step() function:
Uncaught TypeError: bodies[i].integrate is not a function
The step() function is:
this.physicsWorld.step(1 / 60, this.experience.time.delta, 3)
And the docs for the step() function: https://pmndrs.github.io/cannon-es/docs/classes/world.html#step
I can't find anything wrong. What does that error means?

I forgot to import cannon-es instead cannonjs in one file, so I was using a mix of two libraries.

Related

org_scalajs_dom_raw_HTMLDocument(...).createRange is not a function

I'm upgrading scalatags from 0.6.7 to 0.9.3 as part of upgrading scalaJS from 0.6.x to 1.4.0.
I got the following error in some of my tests:
scala.scalajs.js.JavaScriptException: TypeError: $m_Lorg_scalajs_dom_package$(...).document__Lorg_scalajs_dom_raw_HTMLDocument(...).createRange is not a function
Tracing the code, I believe it occurs while executing line 141 of the following scalatags code in `scalatags.JsDom:
I extracted just the createRange call into a separate test and got the same error. "creating range" was printed; "created range" was not and it produced the same exception as above.
createRange() is a native function.
Googling "createRange is not a function" yields a number of similar issues, all seem to be related to testing (but not with ScalaJS). Many of them indicate the "fix" is to monkey-patch document with your own version of createRange. Really?
I initially thought this was an issue with scalatags. Then I thought it's with the scalajs library. Now I'm thinking it's something with Node.js, although Google is not producing any smoking guns.
Suggestions on how to proceed? Try to monkey patch document?
Summary: jsdom appears to be missing the document.createRange function when using Node.js for testing. Others in other languages have similar problems.
The following monkey patch worked for me. After developing this, I noticed that Facade Types has a section on monkey typing.
Also, the library code that tickled this bug (scalatags) actually calls document.createRange().createContextualFragment(v). So I needed to provide something for that as well.
import scala.scalajs.js
import org.scalajs.dom.document
js.Dynamic.global.document.createRange = () ⇒
js.Dynamic.literal(
setStart = () => js.Dynamic.literal(),
setEnd = () => js.Dynamic.literal(),
commonAncestorContainer = js.Dynamic.literal(
nodeName = "BODY",
ownerDocument = document
),
createContextualFragment = (v: String) ⇒ {
val p = document.createElement("p")
p.appendChild(document.createTextNode(v))
}
)

Mongoose 5.3.1 ofFail() helper issues

After reading this blog post (below), I wanted to use the .orFail() helper function in one of my projects.
http://thecodebarbarian.com/whats-new-in-mongoose-53-orfail-and-global-toobject.html
When the function findById() fails, it throws the exception indicated in the .orFail() function. However, when it doesn't fail, it returns "undefined" instead of the actual model object.
let tenants = await Tenant.findById(req.params.tenantId).orFail(new Error(`ID "${req.params.tenantId}" not found`))
Any ideas?
This issue was confirmed as a bug. It's now fixed on 5.3.2
https://github.com/Automattic/mongoose/issues/7099

Unexpected end of input in CoffeeScript

I've started a little game in CoffeScript using canvas.
My problem is this error:
coffee -c -o lib/ src/
/src/interface.coffee:8:48: error: unexpected end of input
#ctx.clearRect 0, 0, #size[0], #size[1]
^
I've rewrote it many times but it still don't want to compile.
Here is the code:
class Interface:
constructor : (id) ->
#canvas = document.getElementById "#{id}"
#ctx = #canvas.getContext "2d"
#size = [#canvas.width, #canvas.height]
clear : () ->
#ctx.clearRect 0, 0, #size[0], #size[1]
Oh, and can someone tell me what exactly this error means?
Thank you in advance.
Its the colon after Interface. An easy way to debug that error for future reference:
Step 1: paste problem code into the 'Try CoffeeScript' part of the coffeescript website to repro the error.
Step 2: erase or comment-out lines until the error goes away and the code compiles
Step 3: the last line you erased was the error.
Step 4: find the error(s) in that line and fix.
Step 5: repeat as necessary.
This is how I figured out what the problem was. This process also works well for the 'Unmatched Outdent' error.

SAPUI5 - Uncaught TypeError: this.getRouter.navTo is not a function

I am referring to the code used in tdg master-detail demokit application.
I am getting an error "Uncaught TypeError: this.getRouter.navTo is not a function".
I have written a console.log("is router fine? "+ this.getRouter().toLocaleString()); before this.getRouter.navTo which prints as
"EventProvider company.accounts_positions_splitpage.MyRouter"
Any suggestions what is the issue?
Thanks
You have to call
this.getRouter().navTo()
instead of
this.getRouter.navTo()
With this.getRouter you do not execute the function, you just get the function as Object. There you try too execute the function navTo(), but that object itselve does not provide such a function.
With this.getRouter() you execute the function and you get the return value (a router) as Object. On that router you can now use navTo(), as you did in your console.log.

Meteor error in trying to use collections

I am currently pulling data from collections in the MongoDB but there are 2 in particular that will not work either giving me the following error:
Exception from sub Assets id i574gxNDc9RdHERNn TypeError: Cannot call method 'find' of undefined
Or:
TypeError: Cannot call method 'attachSchema' of undefined
Or:
Object # has no method 'attachSchema'
depending on how I configure it. Does anyone have an idea of what I am doing wrong. I am using the same code for the ones that work as well as the ones that are throwing errors.
The collection looks like this:
Assets = Collections.Assets = Meteor.Assets;
Querying in server/publish.js:
Meteor.publish("Assets", function (){
return Meteor.Assets.find({});
});
Changing it to:
new Mongo.Collection('Assets');
Gives error:
Exception from sub Assets id ZgzZyNYPmMr5gtFGn TypeError: Cannot call method 'find' of undefined
Running the following from the command line in the top (root) directory of the project might fix this (it helped me):
meteor add aldeed:collection2