# Rotation inside MeshInstance3D surface plane

I'm trying to make a representation of a plane that rotates around a hole in a MeshInstance3D.

So far I've managed to make the circle's hole, but I can't make the plane rotate around the hole. (The hole can't rotate, just the plane)

Here is what I have now:



extends MeshInstance3D

@export var xSize = 20
@export var zSize = 20

@export var update = false
@export var clear_vert_vis = false
var speed = 0.0001

# Called when the node enters the scene tree for the first time.
#generate_terrain(speed : float)
pass # Replace with function body.

func generate_terrain(speed : float):
var a_mesh: ArrayMesh
var surftool = SurfaceTool.new()

var n = FastNoiseLite.new()

n.noise_type = FastNoiseLite.TYPE_PERLIN
n.frequency = 0.1 * speed

surftool.begin(Mesh.PRIMITIVE_TRIANGLES)

for z in range(zSize +1):
for x in range(xSize+1):
var y_variation = cos(speed)
var y = 0 #n.get_noise_2d(x*0.5,z*0.5) * 4* y_variation

var x1 = x -xSize/2
var z1 = z -zSize/2

if inside_circle(xSize/2,x, z, 4):
y = speed * -1
pass
elif around_circle(xSize/2, x, z , 4, 8):
y = n.get_noise_2d(x*0.5,z*0.5) * 4* y_variation
var angle = int(speed) % 90

# x1 and z1 should rotate around center
#x1 = cos(angle)
#z1 = sin(angle)
#rotate(Vector3(0,1,0), angle)

# Place in center 0, 0

# tying to make the rotation, but it is on wrong axis
#var xNew = x1 * cos(speed) - z1 * sin(speed)
#var zNew = x1 * sin(speed) - z1 * cos(speed)

# uv
var uv = Vector2()

uv.x = inverse_lerp(0,xSize, x1)
uv.y = inverse_lerp(0, zSize, z1)
surftool.set_uv(uv)

# vertex

var vert = 0
for z in zSize:
for x in xSize:

vert += 1
vert += 1

surftool.generate_normals()

a_mesh = surftool.commit()

mesh = a_mesh

pass

# return the circle around the plane
func inside_circle(center: float, x: float, z: float, radius : float):
var dx = center - x
var dz = center - z
var distance_squared = dx * dx + dz * dz
enter code here

# return a ring around the circle
func around_circle(center: float, x: float, z: float, inerradius: float, radius : float):
var dx = center - x
var dz = center - z
var distance_squared = dx * dx + dz * dz

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
speed *= 1.01
generate_terrain(speed)

if clear_vert_vis:
for i in get_children():
i.free()
pass



How can I make this plane rotate around the hole, without the hole rotating?

• It's not fully clear to me what it would mean to rotate the plane without also rotating the whole that's part of that plane. Can you elaborate/clarify? Commented Jan 17 at 11:43
• I wish i was able to rotate the points of the mesh, between a ring around the whole. @DMGregory Thanks for the reply Commented Jan 25 at 6:01