Skip to content

Server side rendering

Angel Chang edited this page Sep 23, 2024 · 3 revisions

Server-side rendering

Accessing rendering server

To set up you own local instance of the rendering server, please follow the instructions below.

The /ssc/render endpoint supports the following parameters:

  # Scene selection
  fullId
  floor
  room
  showCeiling - set to true/1/yes to enable

  # Viewpoint
  targetIds - Object ids to show as a comma delimited string
  viewIndex
  camera[view] - JSON object specifying the view (in world coordinates)
  camera[gaps] - gaps string with camera (url encoded)

  # Rendering options

  # Coloring options
  colorBy

  # Image options
  width - image width (default 1024)
  height - image height (default 768)
  

Specifying camera view

The camera view can be specified using the targetIds, viewIndex, or camera parameter.

targetIds

The targetIds is a comma-delimited string of the list of object ids to focus on (the server will try to find a good view point automatically).

http://localhost:8000/ssc/render?fullId=wssScene.scene00085&targetIds=14&width=160&height=120

viewIndex

Predefined views are as follows:

left = 1
right = 2
bottom = 3
top = 4
front = 5
back = 6 

camera

JSON object specifying the camera and view

  type - Camera type ('perspective' or 'orthographic')
  fov - Camera field of view in degrees (default is 50)
  near - Camera near in virtual units (centimeters, default is 10)
  far - Camera far in virtual units (centimeters, default is 40000)
  view - JSON object specifying the view
  gaps - GAPS encoded camera string specifying camera position
camera.view

JSON object specifying the view. NOTE: the scene-toolkit uses a world coordinate frame that may differ from the asset coordinate frame. The following are specified in the world coordinate frame by default.

  coordinate_frame - Use 'scene' to specify coordinates in the scene coordinate frame
  target - array specifying target position to look at 
  position - array specifying camera position
  up - array specifying camera up direction
  lookatUp - array specifying up direction used for computing camera matrix (defaults to camera up)

You can specify a camera that looks at the center of the bounding box of an asset using the following object fields:

  "cameraPositionStrategy": "positionByBBoxOffset",
  "offsetByDim": [0, 1, -1],
  "padByMaxDim": [0, 1, -0.25]

The camera looks at the centroid of the bounding box of the asset, and the camera's position is at: The camera position is determined as follows by these two parameters: cameraPosition = bboxCentroid + (offsetByDim * bboxDimensions/2) + (padByMaxDim * bboxMaximumDimension) This format is used in the configuration files for the ssc/render.js and ssc/render-file.js scripts. For an example, see ssc/config/render_tilted_topdown.json.

Running the server

To run the rendering server, you will need to build the client STK, start the main STK server, and then start the SSC server.

  cd ${STK}
  ./build.sh
  cd ssc
  npm install
  cd ../server
  ./run.sh
  NODE_BASE_URL=http://localhost:8010 ./ssc-server.js

See Troubleshooting for help if the following example links don't work.

Example links:

Looking at object 14 http://localhost:8000/ssc/render?fullId=wssScene.scene00085&targetIds=14&width=160&height=120

Top down view http://localhost:8000/ssc/render?fullId=wssScene.scene00085&viewIndex=4&height=480&width=640&showCeiling=0

Top down view colored by category http://localhost:8000/ssc/render?fullId=wssScene.scene00085&viewIndex=4&height=480&width=640&showCeiling=0&colorBy=category

Top down view colored by object id http://localhost:8000/ssc/render?fullId=wssScene.scene00085&viewIndex=4&height=480&width=640&showCeiling=0&colorBy=objectId

Top down view colored by category for just level 0 http://localhost:8000/ssc/render?fullId=xxx.yyy&viewIndex=4&height=480&width=640&showCeiling=0&colorBy=category&floor=0

Top down view colored by category for just room 0_5 (note the id is split into floor=0 and room=5) http://localhost:8000/ssc/render?fullId=xxx.yyy&viewIndex=4&height=480&width=640&showCeiling=0&colorBy=category&floor=0&room=5

Note also that room view may be missing some doors/windows since currently doors/windows are associated with only one room. Some large rooms will only be partially occupied because there are some smaller rooms embedded within it.

Clone this wiki locally