Menu - Top - Home - Donate to Me


Back to documentation index.


The extras/raypick.js module. To import all symbols in this module, either of the following can be used:

import * from "extras/raypick.js";
// -- or --
import * as CustomModuleName from "extras/raypick.js";


(static) module:extras/raypick.raypick(x, y, projView, viewport, objects)

Finds the three-dimensional shape object and world-space coordinates corresponding to the given two-dimensional (X and Y) coordinates.


Return Value

An object with the following properties:


The following example shows how a hypothetical scene graph could implement picking objects based on the position of the mouse cursor.

var mousePos = scene.getMousePosInPixels();
var viewport = [0, 0, scene.getWidth(), scene.getHeight()];
var projview = scene.getProjectionViewMatrix();
var o = raypick(,, projview, viewport, objects);
if(o.index >= 0) {
pickedShape = objects[o.index];
} else {
pickedShape = null;

Back to documentation index.