Home Reference Source Repository

js/SceneKit/SCNHitTestResult.js

  1. 'use strict'
  2.  
  3. import NSObject from '../ObjectiveC/NSObject'
  4. //import SCNNode from './SCNNode'
  5. //import SCNVector3 from './SCNVector3'
  6. //import SCNMatrix4 from './SCNMatrix4'
  7. //import CGPoint from '../CoreGraphics/CGPoint'
  8.  
  9. /**
  10. * Detailed information about a result from searching for elements of a scene located at a specified point, or along a specified line segment (or ray).
  11. * @access public
  12. * @extends {NSObject}
  13. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult
  14. */
  15. export default class SCNHitTestResult extends NSObject {
  16. /**
  17. * constructor
  18. * @access public
  19. * @constructor
  20. */
  21. constructor() {
  22. super()
  23.  
  24. // Retrieving Information About a Hit-Test Result
  25.  
  26. this._node = null
  27. this._geometryIndex = 0
  28. this._faceIndex = 0
  29. this._localCoordinates = null
  30. this._worldCoordinates = null
  31. this._localNormal = null
  32. this._worldNormal = null
  33. this._modelTransform = null
  34.  
  35. this._distance = null
  36.  
  37. // Instance Properties
  38.  
  39. this._boneNode = null
  40. }
  41.  
  42. // Retrieving Information About a Hit-Test Result
  43.  
  44. /**
  45. * Returns the texture coordinates at the point of intersection for the specified texture mapping channel.
  46. * @access public
  47. * @param {number} channel - The index of the mapping channel in which to look up texture coordinates.
  48. * @returns {CGPoint} -
  49. * @desc An SCNGeometry object can contain multiple sources of texture coordinates, or texture mapping channels. (With multiple channels, you can map texture images for different material properties in different ways.) To use the texture coordinates of a hit-test result, specify which texture coordinate source to look up coordinates in. For example, to add “scorch marks” to a game character hit by a laser, you might modify a texture image mapped to the multiply property of the geometry’s material. Use the mappingChannel index from that material property as the channel parameter when calling textureCoordinates(withMappingChannel:) to ensure that you modify the correct location in the texture image.
  50. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1522771-texturecoordinates
  51. */
  52. textureCoordinatesWithMappingChannel(channel) {
  53. return null
  54. }
  55.  
  56. /**
  57. * The node whose geometry intersects the search ray.
  58. * @type {SCNNode}
  59. * @desc
  60. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1523256-node
  61. */
  62. get node() {
  63. return this._node
  64. }
  65.  
  66. /**
  67. * The index of the geometry element whose surface the search ray intersects.
  68. * @type {number}
  69. * @desc Every SCNGeometry object contains one or more SCNGeometryElement objects that define how its vertices connect to form a surface. This property provides the index of the geometry element intersecting the search ray. For more information about that geometry element, use the geometry’s geometryElement(at:) method.
  70. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1522625-geometryindex
  71. */
  72. get geometryIndex() {
  73. return this._geometryIndex
  74. }
  75.  
  76. /**
  77. * The index of the primitive in the geomety element intersected by the search ray.
  78. * @type {number}
  79. * @desc
  80. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1522888-faceindex
  81. */
  82. get faceIndex() {
  83. return this._faceIndex
  84. }
  85.  
  86. /**
  87. * The point of intersection between the geometry and the search ray, in the local coordinate system of the node containing the geometry.
  88. * @type {SCNVector3}
  89. * @desc
  90. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1523032-localcoordinates
  91. */
  92. get localCoordinates() {
  93. return this._localCoordinates
  94. }
  95.  
  96. /**
  97. * The point of intersection between the geometry and the search ray, in the scene’s world coordinate system.
  98. * @type {SCNVector3}
  99. * @desc
  100. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1523058-worldcoordinates
  101. */
  102. get worldCoordinates() {
  103. return this._worldCoordinates
  104. }
  105.  
  106. /**
  107. * The surface normal vector at the point of intersection, in the local coordinate system of the node containing the geometry intersected by the search ray.
  108. * @type {SCNVector3}
  109. * @desc
  110. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1523953-localnormal
  111. */
  112. get localNormal() {
  113. return this._localNormal
  114. }
  115.  
  116. /**
  117. * The surface normal vector at the point of intersection, in the scene’s world coordinate system.
  118. * @type {SCNVector3}
  119. * @desc
  120. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1524066-worldnormal
  121. */
  122. get worldNormal() {
  123. return this._worldNormal
  124. }
  125.  
  126. /**
  127. * The world transform matrix of the node containing the intersection.
  128. * @type {SCNMatrix4}
  129. * @desc Use this matrix to transform vectors from the local coordinate space of the node whose geometry is intersected by the search ray to the scene’s world coordinate system.
  130. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1523496-modeltransform
  131. */
  132. get modelTransform() {
  133. return this._modelTransform
  134. }
  135.  
  136. // Instance Properties
  137.  
  138. /**
  139. *
  140. * @type {SCNNode}
  141. * @desc
  142. * @see https://developer.apple.com/documentation/scenekit/scnhittestresult/1823463-bonenode
  143. */
  144. get boneNode() {
  145. return this._boneNode
  146. }
  147. }