3D intersection of 2 objects

01-10-2022 03:08 AM
New Contributor III

Hi Developers,

I am working on 3D data in ArcGIS API for JavaScript, I have to perform intersection of 2 objects as height of bus with underpass. as the height of bus or any vehical increases at certain height it will be not allowed to go through that, for this purpose i need to perform intersection.


Please help me in my task as soon as posible. I am open for suggestions.


Thank You

0 Kudos
4 Replies
Esri Contributor


You could use view.hitTest and calculate from the result the difference.
Check also the sample SceneView - hitTest .
Which kind of 3D data are you using?

Let me know if this helps?

New Contributor III

Hi @SaschaBrunnerCH 

I need your precious help in applying hit test between these two objects. one is tree another is Electric line. can you help me in this.

the code is given below

<!-- https://community.esri.com/t5/arcgis-api-for-javascript-questions/change-symbology-in-colorandsizere... -->

<meta charset="utf-8" />

Generate univariate continuous size and color visualization in 3D | Sample
| ArcGIS API for JavaScript 4.22

<script src="https://js.arcgis.com/4.22/"></script>

#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;

#containerDiv {
background-color: white;
padding: 3px;
text-align: center
#slider {
background-color: white;
width: 20px;


#title {
font-size: 14pt;

], (
) => {
const map = new WebScene({
portalItem: {
id: "cee32f0d1548477c83323e9476d11903"

// The minSize and maxSize of volumetric symbols are determined
// based on the view/camera the data will be displayed in.

const view = new SceneView({
container: "viewDiv",
map: map

// Create FeatureLayer instance with popupTemplate


const layer = new FeatureLayer({
url: "https://services8.arcgis.com/Dxp0iiM83fijnVoI/ArcGIS/rest/services/Tree_TH/FeatureServer/0",
visible: true,
popupTemplate: {
// autocasts as new PopupTemplate()
title: "{CITY_NAME}, {CNTRY_NAME}",
content: "Height: {Z}",
fieldInfos: [
fieldName: "Z",

format: {
digitSeparator: false,
places: 0

const symbol = {
type: "unique-value", // autocasts as new UniqueValueRenderer()
field: "REGION",
defaultSymbol: {
type: "line-3d",
field: "arcid",
// autocasts as new LineSymbol3D()
symbolLayers: [{
type: "path", // autocasts as new PathSymbol3DLayer()
profile: "circle",
width: 0.05, // width of the tube in meters
material: { color: [ 0,0,0 ] }

const ETLINE = new FeatureLayer({
url: "https://services8.arcgis.com/Dxp0iiM83fijnVoI/arcgis/rest/services/ETLine/FeatureServer",
renderer: symbol,
outFields: ["*"],
popupTemplate: {
// autocasts as new PopupTemplate()
title: "{Cmn_Name}",
"<i>{Sci_Name}</i><br>" +
"This tree is in {Condition} condition and is {Height} Meter in height."

// configure parameters for the renderer generator.
// the layer must be specified along with a field name
// or arcade expression. The view and other properties determine
// the appropriate default color and size schemes.

const params = {
layer: layer,
field: "Z",
valueUnit: "meter",
view: view,
minValue: 0,
maxValue: 47,
symbolType: "3d-volumetric-uniform",


// Generate a renderer visualizing a single variable
// with continuous color and size based on the
// statistics of the data in the provided layer
// and field name.
// This resolves to an object containing several helpful
// properties, including size/color schemes, statistics,
// the renderer, and visual variables
let rendererResult = null;

view.when().then(() => {
.then((response) => {
// set generated renderer on the layer and add it to the map
rendererResult = response;
response.renderer.classBreakInfos[0].symbol = {
type: "web-style", // autocasts as new WebStyleSymbol()
styleName: "esriRealisticTreesStyle",
name: "Acer",
valueUnit: "meter"
layer.renderer = response.renderer;
if (!layer.visible) {
layer.visible = true;

// generate a histogram for use in the slider. Input the layer
// and field name to generate it.
// You can also use an arcade expression instead of
// a field and normalization field

return histogram({
layer: layer,
field: params.field,
numBins: 100,
minValue: params.minValue,
maxValue: params.maxValue
.then((histogramResult) => {
const slider = ColorSizeSlider.fromRendererResult(
slider.container = "slider";
slider.viewModel.precision = 100;
slider.labelFormatFunction = (value) => {
return parseInt(value.toFixed(0)).toLocaleString();
slider.histogramConfig.standardDeviation = null;
view.ui.add("containerDiv", "bottom-left");

// when the user slides the handle(s), update the renderer
// with the updated color and size visual variable objects

function changeEventHandler() {
const renderer = layer.renderer.clone();
renderer.visualVariables = slider.updateVisualVariables(
layer.renderer = renderer;
///////////////////////////hit test///////////////////////////////////////
/* view
.hitTest(event, { exclude: [view.graphics] })
.then((hitTestResult) => {
// print the information to the panel
hitresultground.textContent = `${Math.round(
)} m`;
hitresultcount.textContent = hitTestResult.results.length;

let lastHit = null;
if (hitTestResult.results.length > 0) {
lastHit =
hitTestResult.results[hitTestResult.results.length - 1];
// create point graphic for each hit on objects
hitTestResult.results.forEach((result, index) => {
const hitObject = new Graphic({
geometry: result.mapPoint,
index === 0 ? ETLINE : layer

slider.on( ["thumb-change", "thumb-drag", "min-change", "max-change"], changeEventHandler);


<div id="viewDiv"></div>
<div id="containerDiv">
<span id="title" class="esri-widget">Tree Height</span>
<div id="slider"></div>

0 Kudos
New Contributor

Thanks   it is really helpful. I will inform You once it will work in my application

0 Kudos
Esri Contributor

Hi, @pragati224

We don't currently support object intersections in 3D, I'm afraid. But if the power cables are line features, you can try out the Elevation Profile Widget and input these cables as Elevation Profile Lines. The widget then draws a section along this line, highlighting any intersections with objects in the view (e.g. the trees).
0 Kudos