Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/XXXX_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add `scene.markerrender` to draw `scatter3d` circle markers as one-vertex discs instead of glyph meshes, which cuts the memory of a marker from 4,160 bytes to 36 bytes [[#XXXX](https://github.com/plotly/plotly.js/pull/XXXX)]
1 change: 1 addition & 0 deletions src/plots/gl3d/layout/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
}

coerce('camera.projection.type');
coerce('markerrender');

/*
* coerce to positive number (min 0) but also do not accept 0 (>0 not >=0)
Expand Down
15 changes: 15 additions & 0 deletions src/plots/gl3d/layout/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ module.exports = {
yaxis: gl3dAxisAttrs,
zaxis: gl3dAxisAttrs,

markerrender: {
valType: 'enumerated',
values: ['glyph', 'disc', 'auto'],
dflt: 'glyph',
editType: 'plot',
description: [
'Sets how circle markers of *scatter3d* traces are drawn.',
'The symbols *circle* and *circle-open* have two forms.',
'*glyph* draws each marker as a mesh of 60 to 104 vertices. This is the default.',
'*disc* draws each marker as one round point sprite. It needs far less memory and draws faster.',
'The edge of a disc differs from the edge of a glyph by about one pixel.',
'A marker with another symbol, a projection on the axes, or a size above the point size limit of the GPU is drawn as a glyph.',
'*auto* is currently the same as *disc*.'
].join(' ')
},
dragmode: {
valType: 'enumerated',
values: ['orbit', 'turntable', 'zoom', 'pan', false],
Expand Down
5 changes: 4 additions & 1 deletion src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,11 @@ proto.toImage = function(format) {
if(!format) format = 'png';
if(scene.staticMode) scene.container.appendChild(STATIC_CANVAS);

// Force redraw
// Force redraw. Disc markers take a slower, smoother edge path on targets without multisampling.
var exportObjs = scene.glplot.objects;
for(var oi = 0; oi < exportObjs.length; oi++) exportObjs[oi].discExport = true;
scene.glplot.redraw();
for(var oj = 0; oj < exportObjs.length; oj++) exportObjs[oj].discExport = false;

// Grab context and yank out pixels
var gl = scene.glplot.gl;
Expand Down
1 change: 1 addition & 0 deletions src/traces/scatter3d/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ proto.update = function (data) {
glyph: options.scatterMarker,
opacity: scatterOpacity,
orthographic: true,
markerRender: this.scene.fullSceneLayout.markerrender,
lineWidth: options.scatterLineWidth,
lineColor: options.scatterLineColor,
project: options.project,
Expand Down
5 changes: 5 additions & 0 deletions src/types/generated/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13742,6 +13742,11 @@ export interface Scene {
* @default 'closest'
*/
hovermode?: 'closest' | false;
/**
* Sets how circle markers of *scatter3d* traces are drawn. The symbols *circle* and *circle-open* have two forms. *glyph* draws each marker as a mesh of 60 to 104 vertices. This is the default. *disc* draws each marker as one round point sprite. It needs far less memory and draws faster. The edge of a disc differs from the edge of a glyph by about one pixel. A marker with another symbol, a projection on the axes, or a size above the point size limit of the GPU is drawn as a glyph. *auto* is currently the same as *disc*.
* @default 'glyph'
*/
markerrender?: 'glyph' | 'disc' | 'auto';
/** Controls persistence of user-driven changes in camera attributes. Defaults to `layout.uirevision`. */
uirevision?: any;
xaxis?: {
Expand Down
Loading
Loading